-- ----------------------------
-- 如果是多租户工程，则需要在租户管理数据库中执行该脚本，既TENANT_ADMIN数据源类型指向的数据库。
-- 这里包含流程引擎自带的数据表和自增序列，以及橙单工作流模块内置的zz_flow开头的数据表。
-- ----------------------------
DROP SEQUENCE IF EXISTS act_evt_log_log_nr__seq;
CREATE SEQUENCE act_evt_log_log_nr__seq
  INCREMENT 1
  START 1
  MINVALUE 1
  MAXVALUE 2147483647
  CACHE 1;
ALTER SEQUENCE act_evt_log_log_nr__seq OWNER TO "vbadmin";

DROP SEQUENCE IF EXISTS act_hi_tsk_log_id__seq;
CREATE SEQUENCE act_hi_tsk_log_id__seq
  INCREMENT 1
  START 1
  MINVALUE 1
  MAXVALUE 2147483647
  CACHE 1;
ALTER SEQUENCE act_hi_tsk_log_id__seq OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_evt_log
-- ----------------------------
DROP TABLE IF EXISTS "act_evt_log";
CREATE TABLE "act_evt_log" (
  "log_nr_" int4 NOT NULL DEFAULT nextval('act_evt_log_log_nr__seq'::regclass),
  "type_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "time_stamp_" timestamp(6) NOT NULL,
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "data_" bytea,
  "lock_owner_" varchar(255) COLLATE "pg_catalog"."default",
  "lock_time_" timestamp(6),
  "is_processed_" int2 DEFAULT 0
);
ALTER TABLE "act_evt_log" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ge_bytearray
-- ----------------------------
DROP TABLE IF EXISTS "act_ge_bytearray";
CREATE TABLE "act_ge_bytearray" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "deployment_id_" varchar(64) COLLATE "pg_catalog"."default",
  "bytes_" bytea,
  "generated_" bool
);
ALTER TABLE "act_ge_bytearray" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ge_property
-- ----------------------------
DROP TABLE IF EXISTS "act_ge_property";
CREATE TABLE "act_ge_property" (
  "name_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "value_" varchar(300) COLLATE "pg_catalog"."default",
  "rev_" int4
);
ALTER TABLE "act_ge_property" OWNER TO "vbadmin";

-- ----------------------------
-- Records of act_ge_property
-- ----------------------------
BEGIN;
INSERT INTO "act_ge_property" VALUES ('common.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('next.dbid', '1', 1);
INSERT INTO "act_ge_property" VALUES ('identitylink.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('entitylink.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('eventsubscription.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('task.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('variable.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('job.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('batch.schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('schema.version', '7.0.1.1', 1);
INSERT INTO "act_ge_property" VALUES ('schema.history', 'create(7.0.1.1)', 1);
INSERT INTO "act_ge_property" VALUES ('cfg.execution-related-entities-count', 'true', 1);
INSERT INTO "act_ge_property" VALUES ('cfg.task-related-entities-count', 'true', 1);
COMMIT;

-- ----------------------------
-- Table structure for act_hi_actinst
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_actinst";
CREATE TABLE "act_hi_actinst" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4 DEFAULT 1,
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "act_id_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "call_proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "act_name_" varchar(255) COLLATE "pg_catalog"."default",
  "act_type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "assignee_" varchar(255) COLLATE "pg_catalog"."default",
  "start_time_" timestamp(6) NOT NULL,
  "end_time_" timestamp(6),
  "transaction_order_" int4,
  "duration_" int8,
  "delete_reason_" varchar(4000) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_hi_actinst" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_attachment
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_attachment";
CREATE TABLE "act_hi_attachment" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "description_" varchar(4000) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "url_" varchar(4000) COLLATE "pg_catalog"."default",
  "content_id_" varchar(64) COLLATE "pg_catalog"."default",
  "time_" timestamp(6)
);
ALTER TABLE "act_hi_attachment" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_comment
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_comment";
CREATE TABLE "act_hi_comment" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "type_" varchar(255) COLLATE "pg_catalog"."default",
  "time_" timestamp(6) NOT NULL,
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "action_" varchar(255) COLLATE "pg_catalog"."default",
  "message_" varchar(4000) COLLATE "pg_catalog"."default",
  "full_msg_" bytea
);
ALTER TABLE "act_hi_comment" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_detail
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_detail";
CREATE TABLE "act_hi_detail" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "act_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "name_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "var_type_" varchar(64) COLLATE "pg_catalog"."default",
  "rev_" int4,
  "time_" timestamp(6) NOT NULL,
  "bytearray_id_" varchar(64) COLLATE "pg_catalog"."default",
  "double_" float8,
  "long_" int8,
  "text_" varchar(4000) COLLATE "pg_catalog"."default",
  "text2_" varchar(4000) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_hi_detail" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_entitylink
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_entitylink";
CREATE TABLE "act_hi_entitylink" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "link_type_" varchar(255) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "parent_element_id_" varchar(255) COLLATE "pg_catalog"."default",
  "ref_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "ref_scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "ref_scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "root_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "root_scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "hierarchy_type_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_hi_entitylink" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_identitylink
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_identitylink";
CREATE TABLE "act_hi_identitylink" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "group_id_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default",
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_hi_identitylink" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_procinst
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_procinst";
CREATE TABLE "act_hi_procinst" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4 DEFAULT 1,
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "business_key_" varchar(255) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "start_time_" timestamp(6) NOT NULL,
  "end_time_" timestamp(6),
  "duration_" int8,
  "start_user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "start_act_id_" varchar(255) COLLATE "pg_catalog"."default",
  "end_act_id_" varchar(255) COLLATE "pg_catalog"."default",
  "super_process_instance_id_" varchar(64) COLLATE "pg_catalog"."default",
  "delete_reason_" varchar(4000) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "callback_id_" varchar(255) COLLATE "pg_catalog"."default",
  "callback_type_" varchar(255) COLLATE "pg_catalog"."default",
  "reference_id_" varchar(255) COLLATE "pg_catalog"."default",
  "reference_type_" varchar(255) COLLATE "pg_catalog"."default",
  "propagated_stage_inst_id_" varchar(255) COLLATE "pg_catalog"."default",
  "business_status_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_hi_procinst" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_taskinst
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_taskinst";
CREATE TABLE "act_hi_taskinst" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4 DEFAULT 1,
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "task_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "task_def_key_" varchar(255) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "propagated_stage_inst_id_" varchar(255) COLLATE "pg_catalog"."default",
  "state_" varchar(255) COLLATE "pg_catalog"."default",
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "parent_task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "description_" varchar(4000) COLLATE "pg_catalog"."default",
  "owner_" varchar(255) COLLATE "pg_catalog"."default",
  "assignee_" varchar(255) COLLATE "pg_catalog"."default",
  "start_time_" timestamp(6) NOT NULL,
  "in_progress_time_" timestamp(6),
  "in_progress_started_by_" varchar(255) COLLATE "pg_catalog"."default",
  "claim_time_" timestamp(6),
  "claimed_by_" varchar(255) COLLATE "pg_catalog"."default",
  "suspended_time_" timestamp(6),
  "suspended_by_" varchar(255) COLLATE "pg_catalog"."default",
  "end_time_" timestamp(6),
  "completed_by_" varchar(255) COLLATE "pg_catalog"."default",
  "duration_" int8,
  "delete_reason_" varchar(4000) COLLATE "pg_catalog"."default",
  "priority_" int4,
  "in_progress_due_date_" timestamp(6),
  "due_date_" timestamp(6),
  "form_key_" varchar(1000) COLLATE "pg_catalog"."default",
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "last_updated_time_" timestamp(6)
);
ALTER TABLE "act_hi_taskinst" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_tsk_log
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_tsk_log";
CREATE TABLE "act_hi_tsk_log" (
  "id_" int4 NOT NULL DEFAULT nextval('act_hi_tsk_log_id__seq'::regclass),
  "type_" varchar(64) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "time_stamp_" timestamp(6) NOT NULL,
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "data_" varchar(4000) COLLATE "pg_catalog"."default",
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_hi_tsk_log" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_hi_varinst
-- ----------------------------
DROP TABLE IF EXISTS "act_hi_varinst";
CREATE TABLE "act_hi_varinst" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4 DEFAULT 1,
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "name_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "var_type_" varchar(100) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "bytearray_id_" varchar(64) COLLATE "pg_catalog"."default",
  "double_" float8,
  "long_" int8,
  "text_" varchar(4000) COLLATE "pg_catalog"."default",
  "text2_" varchar(4000) COLLATE "pg_catalog"."default",
  "meta_info_" varchar(4000) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "last_updated_time_" timestamp(6)
);
ALTER TABLE "act_hi_varinst" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_bytearray
-- ----------------------------
DROP TABLE IF EXISTS "act_id_bytearray";
CREATE TABLE "act_id_bytearray" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "bytes_" bytea
);
ALTER TABLE "act_id_bytearray" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_group
-- ----------------------------
DROP TABLE IF EXISTS "act_id_group";
CREATE TABLE "act_id_group" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_id_group" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_info
-- ----------------------------
DROP TABLE IF EXISTS "act_id_info";
CREATE TABLE "act_id_info" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "user_id_" varchar(64) COLLATE "pg_catalog"."default",
  "type_" varchar(64) COLLATE "pg_catalog"."default",
  "key_" varchar(255) COLLATE "pg_catalog"."default",
  "value_" varchar(255) COLLATE "pg_catalog"."default",
  "password_" bytea,
  "parent_id_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_id_info" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_membership
-- ----------------------------
DROP TABLE IF EXISTS "act_id_membership";
CREATE TABLE "act_id_membership" (
  "user_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "group_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL
);
ALTER TABLE "act_id_membership" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_priv
-- ----------------------------
DROP TABLE IF EXISTS "act_id_priv";
CREATE TABLE "act_id_priv" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "name_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL
);
ALTER TABLE "act_id_priv" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_priv_mapping
-- ----------------------------
DROP TABLE IF EXISTS "act_id_priv_mapping";
CREATE TABLE "act_id_priv_mapping" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "priv_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "group_id_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_id_priv_mapping" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_property
-- ----------------------------
DROP TABLE IF EXISTS "act_id_property";
CREATE TABLE "act_id_property" (
  "name_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "value_" varchar(300) COLLATE "pg_catalog"."default",
  "rev_" int4
);
ALTER TABLE "act_id_property" OWNER TO "vbadmin";

-- ----------------------------
-- Records of act_id_property
-- ----------------------------
BEGIN;
INSERT INTO "act_id_property" VALUES ('schema.version', '7.0.1.1', 1);
COMMIT;

-- ----------------------------
-- Table structure for act_id_token
-- ----------------------------
DROP TABLE IF EXISTS "act_id_token";
CREATE TABLE "act_id_token" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "token_value_" varchar(255) COLLATE "pg_catalog"."default",
  "token_date_" timestamp(6),
  "ip_address_" varchar(255) COLLATE "pg_catalog"."default",
  "user_agent_" varchar(255) COLLATE "pg_catalog"."default",
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "token_data_" varchar(2000) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_id_token" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_id_user
-- ----------------------------
DROP TABLE IF EXISTS "act_id_user";
CREATE TABLE "act_id_user" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "first_" varchar(255) COLLATE "pg_catalog"."default",
  "last_" varchar(255) COLLATE "pg_catalog"."default",
  "display_name_" varchar(255) COLLATE "pg_catalog"."default",
  "email_" varchar(255) COLLATE "pg_catalog"."default",
  "pwd_" varchar(255) COLLATE "pg_catalog"."default",
  "picture_id_" varchar(64) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_id_user" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_procdef_info
-- ----------------------------
DROP TABLE IF EXISTS "act_procdef_info";
CREATE TABLE "act_procdef_info" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "info_json_id_" varchar(64) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_procdef_info" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_re_deployment
-- ----------------------------
DROP TABLE IF EXISTS "act_re_deployment";
CREATE TABLE "act_re_deployment" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "key_" varchar(255) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "deploy_time_" timestamp(6),
  "derived_from_" varchar(64) COLLATE "pg_catalog"."default",
  "derived_from_root_" varchar(64) COLLATE "pg_catalog"."default",
  "parent_deployment_id_" varchar(255) COLLATE "pg_catalog"."default",
  "engine_version_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_re_deployment" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_re_model
-- ----------------------------
DROP TABLE IF EXISTS "act_re_model";
CREATE TABLE "act_re_model" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "key_" varchar(255) COLLATE "pg_catalog"."default",
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "last_update_time_" timestamp(6),
  "version_" int4,
  "meta_info_" varchar(4000) COLLATE "pg_catalog"."default",
  "deployment_id_" varchar(64) COLLATE "pg_catalog"."default",
  "editor_source_value_id_" varchar(64) COLLATE "pg_catalog"."default",
  "editor_source_extra_value_id_" varchar(64) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_re_model" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_re_procdef
-- ----------------------------
DROP TABLE IF EXISTS "act_re_procdef";
CREATE TABLE "act_re_procdef" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "key_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "version_" int4 NOT NULL,
  "deployment_id_" varchar(64) COLLATE "pg_catalog"."default",
  "resource_name_" varchar(4000) COLLATE "pg_catalog"."default",
  "dgrm_resource_name_" varchar(4000) COLLATE "pg_catalog"."default",
  "description_" varchar(4000) COLLATE "pg_catalog"."default",
  "has_start_form_key_" bool,
  "has_graphical_notation_" bool,
  "suspension_state_" int4,
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "derived_from_" varchar(64) COLLATE "pg_catalog"."default",
  "derived_from_root_" varchar(64) COLLATE "pg_catalog"."default",
  "derived_version_" int4 NOT NULL DEFAULT 0,
  "engine_version_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_re_procdef" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_actinst
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_actinst";
CREATE TABLE "act_ru_actinst" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4 DEFAULT 1,
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "act_id_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "call_proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "act_name_" varchar(255) COLLATE "pg_catalog"."default",
  "act_type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "assignee_" varchar(255) COLLATE "pg_catalog"."default",
  "start_time_" timestamp(6) NOT NULL,
  "end_time_" timestamp(6),
  "duration_" int8,
  "transaction_order_" int4,
  "delete_reason_" varchar(4000) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_actinst" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_deadletter_job
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_deadletter_job";
CREATE TABLE "act_ru_deadletter_job" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "exclusive_" bool,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "process_instance_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "element_id_" varchar(255) COLLATE "pg_catalog"."default",
  "element_name_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "correlation_id_" varchar(255) COLLATE "pg_catalog"."default",
  "exception_stack_id_" varchar(64) COLLATE "pg_catalog"."default",
  "exception_msg_" varchar(4000) COLLATE "pg_catalog"."default",
  "duedate_" timestamp(6),
  "repeat_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_type_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_cfg_" varchar(4000) COLLATE "pg_catalog"."default",
  "custom_values_id_" varchar(64) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_deadletter_job" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_entitylink
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_entitylink";
CREATE TABLE "act_ru_entitylink" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "create_time_" timestamp(6),
  "link_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "parent_element_id_" varchar(255) COLLATE "pg_catalog"."default",
  "ref_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "ref_scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "ref_scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "root_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "root_scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "hierarchy_type_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_ru_entitylink" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_event_subscr
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_event_subscr";
CREATE TABLE "act_ru_event_subscr" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "event_type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "event_name_" varchar(255) COLLATE "pg_catalog"."default",
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "activity_id_" varchar(64) COLLATE "pg_catalog"."default",
  "configuration_" varchar(255) COLLATE "pg_catalog"."default",
  "created_" timestamp(6) NOT NULL,
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_definition_key_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(64) COLLATE "pg_catalog"."default",
  "lock_time_" timestamp(6),
  "lock_owner_" varchar(255) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_event_subscr" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_execution
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_execution";
CREATE TABLE "act_ru_execution" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "business_key_" varchar(255) COLLATE "pg_catalog"."default",
  "parent_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "super_exec_" varchar(64) COLLATE "pg_catalog"."default",
  "root_proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "act_id_" varchar(255) COLLATE "pg_catalog"."default",
  "is_active_" bool,
  "is_concurrent_" bool,
  "is_scope_" bool,
  "is_event_scope_" bool,
  "is_mi_root_" bool,
  "suspension_state_" int4,
  "cached_ent_state_" int4,
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "start_act_id_" varchar(255) COLLATE "pg_catalog"."default",
  "start_time_" timestamp(6),
  "start_user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "lock_time_" timestamp(6),
  "lock_owner_" varchar(255) COLLATE "pg_catalog"."default",
  "is_count_enabled_" bool,
  "evt_subscr_count_" int4,
  "task_count_" int4,
  "job_count_" int4,
  "timer_job_count_" int4,
  "susp_job_count_" int4,
  "deadletter_job_count_" int4,
  "external_worker_job_count_" int4,
  "var_count_" int4,
  "id_link_count_" int4,
  "callback_id_" varchar(255) COLLATE "pg_catalog"."default",
  "callback_type_" varchar(255) COLLATE "pg_catalog"."default",
  "reference_id_" varchar(255) COLLATE "pg_catalog"."default",
  "reference_type_" varchar(255) COLLATE "pg_catalog"."default",
  "propagated_stage_inst_id_" varchar(255) COLLATE "pg_catalog"."default",
  "business_status_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_ru_execution" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_external_job
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_external_job";
CREATE TABLE "act_ru_external_job" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "lock_exp_time_" timestamp(6),
  "lock_owner_" varchar(255) COLLATE "pg_catalog"."default",
  "exclusive_" bool,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "process_instance_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "element_id_" varchar(255) COLLATE "pg_catalog"."default",
  "element_name_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "correlation_id_" varchar(255) COLLATE "pg_catalog"."default",
  "retries_" int4,
  "exception_stack_id_" varchar(64) COLLATE "pg_catalog"."default",
  "exception_msg_" varchar(4000) COLLATE "pg_catalog"."default",
  "duedate_" timestamp(6),
  "repeat_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_type_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_cfg_" varchar(4000) COLLATE "pg_catalog"."default",
  "custom_values_id_" varchar(64) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_external_job" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_history_job
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_history_job";
CREATE TABLE "act_ru_history_job" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "lock_exp_time_" timestamp(6),
  "lock_owner_" varchar(255) COLLATE "pg_catalog"."default",
  "retries_" int4,
  "exception_stack_id_" varchar(64) COLLATE "pg_catalog"."default",
  "exception_msg_" varchar(4000) COLLATE "pg_catalog"."default",
  "handler_type_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_cfg_" varchar(4000) COLLATE "pg_catalog"."default",
  "custom_values_id_" varchar(64) COLLATE "pg_catalog"."default",
  "adv_handler_cfg_id_" varchar(64) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_history_job" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_identitylink
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_identitylink";
CREATE TABLE "act_ru_identitylink" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "group_id_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default",
  "user_id_" varchar(255) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_ru_identitylink" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_job
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_job";
CREATE TABLE "act_ru_job" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "lock_exp_time_" timestamp(6),
  "lock_owner_" varchar(255) COLLATE "pg_catalog"."default",
  "exclusive_" bool,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "process_instance_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "element_id_" varchar(255) COLLATE "pg_catalog"."default",
  "element_name_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "correlation_id_" varchar(255) COLLATE "pg_catalog"."default",
  "retries_" int4,
  "exception_stack_id_" varchar(64) COLLATE "pg_catalog"."default",
  "exception_msg_" varchar(4000) COLLATE "pg_catalog"."default",
  "duedate_" timestamp(6),
  "repeat_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_type_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_cfg_" varchar(4000) COLLATE "pg_catalog"."default",
  "custom_values_id_" varchar(64) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_job" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_suspended_job
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_suspended_job";
CREATE TABLE "act_ru_suspended_job" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "exclusive_" bool,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "process_instance_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "element_id_" varchar(255) COLLATE "pg_catalog"."default",
  "element_name_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "correlation_id_" varchar(255) COLLATE "pg_catalog"."default",
  "retries_" int4,
  "exception_stack_id_" varchar(64) COLLATE "pg_catalog"."default",
  "exception_msg_" varchar(4000) COLLATE "pg_catalog"."default",
  "duedate_" timestamp(6),
  "repeat_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_type_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_cfg_" varchar(4000) COLLATE "pg_catalog"."default",
  "custom_values_id_" varchar(64) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_suspended_job" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_task
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_task";
CREATE TABLE "act_ru_task" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "task_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "propagated_stage_inst_id_" varchar(255) COLLATE "pg_catalog"."default",
  "state_" varchar(255) COLLATE "pg_catalog"."default",
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "parent_task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "description_" varchar(4000) COLLATE "pg_catalog"."default",
  "task_def_key_" varchar(255) COLLATE "pg_catalog"."default",
  "owner_" varchar(255) COLLATE "pg_catalog"."default",
  "assignee_" varchar(255) COLLATE "pg_catalog"."default",
  "delegation_" varchar(64) COLLATE "pg_catalog"."default",
  "priority_" int4,
  "create_time_" timestamp(6),
  "in_progress_time_" timestamp(6),
  "in_progress_started_by_" varchar(255) COLLATE "pg_catalog"."default",
  "claim_time_" timestamp(6),
  "claimed_by_" varchar(255) COLLATE "pg_catalog"."default",
  "suspended_time_" timestamp(6),
  "suspended_by_" varchar(255) COLLATE "pg_catalog"."default",
  "in_progress_due_date_" timestamp(6),
  "due_date_" timestamp(6),
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "suspension_state_" int4,
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "form_key_" varchar(1000) COLLATE "pg_catalog"."default",
  "is_count_enabled_" bool,
  "var_count_" int4,
  "id_link_count_" int4,
  "sub_task_count_" int4
);
ALTER TABLE "act_ru_task" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_timer_job
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_timer_job";
CREATE TABLE "act_ru_timer_job" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "lock_exp_time_" timestamp(6),
  "lock_owner_" varchar(255) COLLATE "pg_catalog"."default",
  "exclusive_" bool,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "process_instance_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_def_id_" varchar(64) COLLATE "pg_catalog"."default",
  "element_id_" varchar(255) COLLATE "pg_catalog"."default",
  "element_name_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_definition_id_" varchar(255) COLLATE "pg_catalog"."default",
  "correlation_id_" varchar(255) COLLATE "pg_catalog"."default",
  "retries_" int4,
  "exception_stack_id_" varchar(64) COLLATE "pg_catalog"."default",
  "exception_msg_" varchar(4000) COLLATE "pg_catalog"."default",
  "duedate_" timestamp(6),
  "repeat_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_type_" varchar(255) COLLATE "pg_catalog"."default",
  "handler_cfg_" varchar(4000) COLLATE "pg_catalog"."default",
  "custom_values_id_" varchar(64) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6),
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "act_ru_timer_job" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for act_ru_variable
-- ----------------------------
DROP TABLE IF EXISTS "act_ru_variable";
CREATE TABLE "act_ru_variable" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "type_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "name_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "execution_id_" varchar(64) COLLATE "pg_catalog"."default",
  "proc_inst_id_" varchar(64) COLLATE "pg_catalog"."default",
  "task_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(255) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(255) COLLATE "pg_catalog"."default",
  "bytearray_id_" varchar(64) COLLATE "pg_catalog"."default",
  "double_" float8,
  "long_" int8,
  "text_" varchar(4000) COLLATE "pg_catalog"."default",
  "text2_" varchar(4000) COLLATE "pg_catalog"."default",
  "meta_info_" varchar(4000) COLLATE "pg_catalog"."default"
);
ALTER TABLE "act_ru_variable" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for flw_channel_definition
-- ----------------------------
DROP TABLE IF EXISTS "flw_channel_definition";
CREATE TABLE "flw_channel_definition" (
  "id_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "version_" int4,
  "key_" varchar(255) COLLATE "pg_catalog"."default",
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "deployment_id_" varchar(255) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(3),
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default",
  "resource_name_" varchar(255) COLLATE "pg_catalog"."default",
  "description_" varchar(255) COLLATE "pg_catalog"."default",
  "type_" varchar(255) COLLATE "pg_catalog"."default",
  "implementation_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "flw_channel_definition" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for flw_ev_databasechangelog
-- ----------------------------
DROP TABLE IF EXISTS "flw_ev_databasechangelog";
CREATE TABLE "flw_ev_databasechangelog" (
  "id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "author" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "filename" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "dateexecuted" timestamp(6) NOT NULL,
  "orderexecuted" int4 NOT NULL,
  "exectype" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
  "md5sum" varchar(35) COLLATE "pg_catalog"."default",
  "description" varchar(255) COLLATE "pg_catalog"."default",
  "comments" varchar(255) COLLATE "pg_catalog"."default",
  "tag" varchar(255) COLLATE "pg_catalog"."default",
  "liquibase" varchar(20) COLLATE "pg_catalog"."default",
  "contexts" varchar(255) COLLATE "pg_catalog"."default",
  "labels" varchar(255) COLLATE "pg_catalog"."default",
  "deployment_id" varchar(10) COLLATE "pg_catalog"."default"
);
ALTER TABLE "flw_ev_databasechangelog" OWNER TO "vbadmin";

-- ----------------------------
-- Records of flw_ev_databasechangelog
-- ----------------------------
BEGIN;
INSERT INTO "flw_ev_databasechangelog" VALUES ('1', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 17:29:02.148665', 1, 'EXECUTED', '8:1b0c48c9cf7945be799d868a2626d687', 'createTable tableName=FLW_EVENT_DEPLOYMENT; createTable tableName=FLW_EVENT_RESOURCE; createTable tableName=FLW_EVENT_DEFINITION; createIndex indexName=ACT_IDX_EVENT_DEF_UNIQ, tableName=FLW_EVENT_DEFINITION; createTable tableName=FLW_CHANNEL_DEFIN...', '', NULL, '4.20.0', NULL, NULL, '6002140819');
INSERT INTO "flw_ev_databasechangelog" VALUES ('2', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 17:29:03.508416', 2, 'EXECUTED', '8:0ea825feb8e470558f0b5754352b9cda', 'addColumn tableName=FLW_CHANNEL_DEFINITION; addColumn tableName=FLW_CHANNEL_DEFINITION', '', NULL, '4.20.0', NULL, NULL, '6002140819');
INSERT INTO "flw_ev_databasechangelog" VALUES ('3', 'flowable', 'org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml', '2024-01-23 17:29:04.178424', 3, 'EXECUTED', '8:3c2bb293350b5cbe6504331980c9dcee', 'customChange', '', NULL, '4.20.0', NULL, NULL, '6002140819');
COMMIT;

-- ----------------------------
-- Table structure for flw_ev_databasechangeloglock
-- ----------------------------
DROP TABLE IF EXISTS "flw_ev_databasechangeloglock";
CREATE TABLE "flw_ev_databasechangeloglock" (
  "id" int4 NOT NULL,
  "locked" bool NOT NULL,
  "lockgranted" timestamp(6),
  "lockedby" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "flw_ev_databasechangeloglock" OWNER TO "vbadmin";

-- ----------------------------
-- Records of flw_ev_databasechangeloglock
-- ----------------------------
BEGIN;
INSERT INTO "flw_ev_databasechangeloglock" VALUES (1, 'f', NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for flw_event_definition
-- ----------------------------
DROP TABLE IF EXISTS "flw_event_definition";
CREATE TABLE "flw_event_definition" (
  "id_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "version_" int4,
  "key_" varchar(255) COLLATE "pg_catalog"."default",
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "deployment_id_" varchar(255) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default",
  "resource_name_" varchar(255) COLLATE "pg_catalog"."default",
  "description_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "flw_event_definition" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for flw_event_deployment
-- ----------------------------
DROP TABLE IF EXISTS "flw_event_deployment";
CREATE TABLE "flw_event_deployment" (
  "id_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "category_" varchar(255) COLLATE "pg_catalog"."default",
  "deploy_time_" timestamp(3),
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default",
  "parent_deployment_id_" varchar(255) COLLATE "pg_catalog"."default"
);
ALTER TABLE "flw_event_deployment" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for flw_event_resource
-- ----------------------------
DROP TABLE IF EXISTS "flw_event_resource";
CREATE TABLE "flw_event_resource" (
  "id_" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "name_" varchar(255) COLLATE "pg_catalog"."default",
  "deployment_id_" varchar(255) COLLATE "pg_catalog"."default",
  "resource_bytes_" bytea
);
ALTER TABLE "flw_event_resource" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for flw_ru_batch
-- ----------------------------
DROP TABLE IF EXISTS "flw_ru_batch";
CREATE TABLE "flw_ru_batch" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "type_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "search_key_" varchar(255) COLLATE "pg_catalog"."default",
  "search_key2_" varchar(255) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6) NOT NULL,
  "complete_time_" timestamp(6),
  "status_" varchar(255) COLLATE "pg_catalog"."default",
  "batch_doc_id_" varchar(64) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "flw_ru_batch" OWNER TO "vbadmin";

-- ----------------------------
-- Table structure for flw_ru_batch_part
-- ----------------------------
DROP TABLE IF EXISTS "flw_ru_batch_part";
CREATE TABLE "flw_ru_batch_part" (
  "id_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "rev_" int4,
  "batch_id_" varchar(64) COLLATE "pg_catalog"."default",
  "type_" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "scope_id_" varchar(64) COLLATE "pg_catalog"."default",
  "sub_scope_id_" varchar(64) COLLATE "pg_catalog"."default",
  "scope_type_" varchar(64) COLLATE "pg_catalog"."default",
  "search_key_" varchar(255) COLLATE "pg_catalog"."default",
  "search_key2_" varchar(255) COLLATE "pg_catalog"."default",
  "create_time_" timestamp(6) NOT NULL,
  "complete_time_" timestamp(6),
  "status_" varchar(255) COLLATE "pg_catalog"."default",
  "result_doc_id_" varchar(64) COLLATE "pg_catalog"."default",
  "tenant_id_" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying
);
ALTER TABLE "flw_ru_batch_part" OWNER TO "vbadmin";

-- ----------------------------
-- Primary Key structure for table act_evt_log
-- ----------------------------
ALTER TABLE "act_evt_log" ADD CONSTRAINT "act_evt_log_pkey" PRIMARY KEY ("log_nr_");

-- ----------------------------
-- Indexes structure for table act_ge_bytearray
-- ----------------------------
CREATE INDEX "act_idx_bytear_depl" ON "act_ge_bytearray" USING btree (
  "deployment_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ge_bytearray
-- ----------------------------
ALTER TABLE "act_ge_bytearray" ADD CONSTRAINT "act_ge_bytearray_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_ge_property
-- ----------------------------
ALTER TABLE "act_ge_property" ADD CONSTRAINT "act_ge_property_pkey" PRIMARY KEY ("name_");

-- ----------------------------
-- Indexes structure for table act_hi_actinst
-- ----------------------------
CREATE INDEX "act_idx_hi_act_inst_end" ON "act_hi_actinst" USING btree (
  "end_time_"  ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_act_inst_exec" ON "act_hi_actinst" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "act_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_act_inst_procinst" ON "act_hi_actinst" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "act_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_act_inst_start" ON "act_hi_actinst" USING btree (
  "start_time_"  ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_hi_actinst
-- ----------------------------
ALTER TABLE "act_hi_actinst" ADD CONSTRAINT "act_hi_actinst_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_hi_attachment
-- ----------------------------
ALTER TABLE "act_hi_attachment" ADD CONSTRAINT "act_hi_attachment_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_hi_comment
-- ----------------------------
ALTER TABLE "act_hi_comment" ADD CONSTRAINT "act_hi_comment_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_hi_detail
-- ----------------------------
CREATE INDEX "act_idx_hi_detail_act_inst" ON "act_hi_detail" USING btree (
  "act_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_detail_name" ON "act_hi_detail" USING btree (
  "name_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_detail_proc_inst" ON "act_hi_detail" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_detail_task_id" ON "act_hi_detail" USING btree (
  "task_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_detail_time" ON "act_hi_detail" USING btree (
  "time_"  ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_hi_detail
-- ----------------------------
ALTER TABLE "act_hi_detail" ADD CONSTRAINT "act_hi_detail_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_hi_entitylink
-- ----------------------------
CREATE INDEX "act_idx_hi_ent_lnk_ref_scope" ON "act_hi_entitylink" USING btree (
  "ref_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "ref_scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ent_lnk_root_scope" ON "act_hi_entitylink" USING btree (
  "root_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "root_scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ent_lnk_scope" ON "act_hi_entitylink" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ent_lnk_scope_def" ON "act_hi_entitylink" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_hi_entitylink
-- ----------------------------
ALTER TABLE "act_hi_entitylink" ADD CONSTRAINT "act_hi_entitylink_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_hi_identitylink
-- ----------------------------
CREATE INDEX "act_idx_hi_ident_lnk_procinst" ON "act_hi_identitylink" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ident_lnk_scope" ON "act_hi_identitylink" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ident_lnk_scope_def" ON "act_hi_identitylink" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ident_lnk_sub_scope" ON "act_hi_identitylink" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ident_lnk_task" ON "act_hi_identitylink" USING btree (
  "task_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_ident_lnk_user" ON "act_hi_identitylink" USING btree (
  "user_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_hi_identitylink
-- ----------------------------
ALTER TABLE "act_hi_identitylink" ADD CONSTRAINT "act_hi_identitylink_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_hi_procinst
-- ----------------------------
CREATE INDEX "act_idx_hi_pro_i_buskey" ON "act_hi_procinst" USING btree (
  "business_key_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_pro_inst_end" ON "act_hi_procinst" USING btree (
  "end_time_"  ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_pro_super_procinst" ON "act_hi_procinst" USING btree (
  "super_process_instance_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Uniques structure for table act_hi_procinst
-- ----------------------------
ALTER TABLE "act_hi_procinst" ADD CONSTRAINT "act_hi_procinst_proc_inst_id__key" UNIQUE ("proc_inst_id_");

-- ----------------------------
-- Primary Key structure for table act_hi_procinst
-- ----------------------------
ALTER TABLE "act_hi_procinst" ADD CONSTRAINT "act_hi_procinst_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_hi_taskinst
-- ----------------------------
CREATE INDEX "act_idx_hi_task_inst_procinst" ON "act_hi_taskinst" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_task_scope" ON "act_hi_taskinst" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_task_scope_def" ON "act_hi_taskinst" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_task_sub_scope" ON "act_hi_taskinst" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_hi_taskinst
-- ----------------------------
ALTER TABLE "act_hi_taskinst" ADD CONSTRAINT "act_hi_taskinst_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_hi_tsk_log
-- ----------------------------
ALTER TABLE "act_hi_tsk_log" ADD CONSTRAINT "act_hi_tsk_log_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_hi_varinst
-- ----------------------------
CREATE INDEX "act_idx_hi_procvar_exe" ON "act_hi_varinst" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_procvar_name_type" ON "act_hi_varinst" USING btree (
  "name_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "var_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_procvar_proc_inst" ON "act_hi_varinst" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_procvar_task_id" ON "act_hi_varinst" USING btree (
  "task_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_var_scope_id_type" ON "act_hi_varinst" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_hi_var_sub_id_type" ON "act_hi_varinst" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_hi_varinst
-- ----------------------------
ALTER TABLE "act_hi_varinst" ADD CONSTRAINT "act_hi_varinst_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_id_bytearray
-- ----------------------------
ALTER TABLE "act_id_bytearray" ADD CONSTRAINT "act_id_bytearray_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_id_group
-- ----------------------------
ALTER TABLE "act_id_group" ADD CONSTRAINT "act_id_group_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_id_info
-- ----------------------------
ALTER TABLE "act_id_info" ADD CONSTRAINT "act_id_info_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_id_membership
-- ----------------------------
CREATE INDEX "act_idx_memb_group" ON "act_id_membership" USING btree (
  "group_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_memb_user" ON "act_id_membership" USING btree (
  "user_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_id_membership
-- ----------------------------
ALTER TABLE "act_id_membership" ADD CONSTRAINT "act_id_membership_pkey" PRIMARY KEY ("user_id_", "group_id_");

-- ----------------------------
-- Uniques structure for table act_id_priv
-- ----------------------------
ALTER TABLE "act_id_priv" ADD CONSTRAINT "act_uniq_priv_name" UNIQUE ("name_");

-- ----------------------------
-- Primary Key structure for table act_id_priv
-- ----------------------------
ALTER TABLE "act_id_priv" ADD CONSTRAINT "act_id_priv_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_id_priv_mapping
-- ----------------------------
CREATE INDEX "act_idx_priv_group" ON "act_id_priv_mapping" USING btree (
  "group_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_priv_mapping" ON "act_id_priv_mapping" USING btree (
  "priv_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_priv_user" ON "act_id_priv_mapping" USING btree (
  "user_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_id_priv_mapping
-- ----------------------------
ALTER TABLE "act_id_priv_mapping" ADD CONSTRAINT "act_id_priv_mapping_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_id_property
-- ----------------------------
ALTER TABLE "act_id_property" ADD CONSTRAINT "act_id_property_pkey" PRIMARY KEY ("name_");

-- ----------------------------
-- Primary Key structure for table act_id_token
-- ----------------------------
ALTER TABLE "act_id_token" ADD CONSTRAINT "act_id_token_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_id_user
-- ----------------------------
ALTER TABLE "act_id_user" ADD CONSTRAINT "act_id_user_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_procdef_info
-- ----------------------------
CREATE INDEX "act_idx_procdef_info_json" ON "act_procdef_info" USING btree (
  "info_json_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_procdef_info_proc" ON "act_procdef_info" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Uniques structure for table act_procdef_info
-- ----------------------------
ALTER TABLE "act_procdef_info" ADD CONSTRAINT "act_uniq_info_procdef" UNIQUE ("proc_def_id_");

-- ----------------------------
-- Primary Key structure for table act_procdef_info
-- ----------------------------
ALTER TABLE "act_procdef_info" ADD CONSTRAINT "act_procdef_info_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_re_deployment
-- ----------------------------
ALTER TABLE "act_re_deployment" ADD CONSTRAINT "act_re_deployment_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_re_model
-- ----------------------------
CREATE INDEX "act_idx_model_deployment" ON "act_re_model" USING btree (
  "deployment_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_model_source" ON "act_re_model" USING btree (
  "editor_source_value_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_model_source_extra" ON "act_re_model" USING btree (
  "editor_source_extra_value_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_re_model
-- ----------------------------
ALTER TABLE "act_re_model" ADD CONSTRAINT "act_re_model_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Uniques structure for table act_re_procdef
-- ----------------------------
ALTER TABLE "act_re_procdef" ADD CONSTRAINT "act_uniq_procdef" UNIQUE ("key_", "version_", "derived_version_", "tenant_id_");

-- ----------------------------
-- Primary Key structure for table act_re_procdef
-- ----------------------------
ALTER TABLE "act_re_procdef" ADD CONSTRAINT "act_re_procdef_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_actinst
-- ----------------------------
CREATE INDEX "act_idx_ru_acti_end" ON "act_ru_actinst" USING btree (
  "end_time_"  ASC NULLS LAST
);
CREATE INDEX "act_idx_ru_acti_exec" ON "act_ru_actinst" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ru_acti_exec_act" ON "act_ru_actinst" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "act_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ru_acti_proc" ON "act_ru_actinst" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ru_acti_proc_act" ON "act_ru_actinst" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "act_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ru_acti_start" ON "act_ru_actinst" USING btree (
  "start_time_"  ASC NULLS LAST
);
CREATE INDEX "act_idx_ru_acti_task" ON "act_ru_actinst" USING btree (
  "task_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_actinst
-- ----------------------------
ALTER TABLE "act_ru_actinst" ADD CONSTRAINT "act_ru_actinst_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_deadletter_job
-- ----------------------------
CREATE INDEX "act_idx_deadletter_job_correlation_id" ON "act_ru_deadletter_job" USING btree (
  "correlation_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_deadletter_job_custom_values_id" ON "act_ru_deadletter_job" USING btree (
  "custom_values_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_deadletter_job_exception_stack_id" ON "act_ru_deadletter_job" USING btree (
  "exception_stack_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_deadletter_job_execution_id" ON "act_ru_deadletter_job" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_deadletter_job_proc_def_id" ON "act_ru_deadletter_job" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_deadletter_job_process_instance_id" ON "act_ru_deadletter_job" USING btree (
  "process_instance_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_djob_scope" ON "act_ru_deadletter_job" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_djob_scope_def" ON "act_ru_deadletter_job" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_djob_sub_scope" ON "act_ru_deadletter_job" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_deadletter_job
-- ----------------------------
ALTER TABLE "act_ru_deadletter_job" ADD CONSTRAINT "act_ru_deadletter_job_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_entitylink
-- ----------------------------
CREATE INDEX "act_idx_ent_lnk_ref_scope" ON "act_ru_entitylink" USING btree (
  "ref_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "ref_scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ent_lnk_root_scope" ON "act_ru_entitylink" USING btree (
  "root_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "root_scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ent_lnk_scope" ON "act_ru_entitylink" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ent_lnk_scope_def" ON "act_ru_entitylink" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "link_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_entitylink
-- ----------------------------
ALTER TABLE "act_ru_entitylink" ADD CONSTRAINT "act_ru_entitylink_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_event_subscr
-- ----------------------------
CREATE INDEX "act_idx_event_subscr" ON "act_ru_event_subscr" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_event_subscr_config_" ON "act_ru_event_subscr" USING btree (
  "configuration_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_event_subscr_scoperef_" ON "act_ru_event_subscr" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_event_subscr
-- ----------------------------
ALTER TABLE "act_ru_event_subscr" ADD CONSTRAINT "act_ru_event_subscr_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_execution
-- ----------------------------
CREATE INDEX "act_idx_exe_parent" ON "act_ru_execution" USING btree (
  "parent_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_exe_procdef" ON "act_ru_execution" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_exe_procinst" ON "act_ru_execution" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_exe_root" ON "act_ru_execution" USING btree (
  "root_proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_exe_super" ON "act_ru_execution" USING btree (
  "super_exec_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_exec_buskey" ON "act_ru_execution" USING btree (
  "business_key_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_exec_ref_id_" ON "act_ru_execution" USING btree (
  "reference_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_execution
-- ----------------------------
ALTER TABLE "act_ru_execution" ADD CONSTRAINT "act_ru_execution_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_external_job
-- ----------------------------
CREATE INDEX "act_idx_ejob_scope" ON "act_ru_external_job" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ejob_scope_def" ON "act_ru_external_job" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ejob_sub_scope" ON "act_ru_external_job" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_external_job_correlation_id" ON "act_ru_external_job" USING btree (
  "correlation_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_external_job_custom_values_id" ON "act_ru_external_job" USING btree (
  "custom_values_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_external_job_exception_stack_id" ON "act_ru_external_job" USING btree (
  "exception_stack_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_external_job
-- ----------------------------
ALTER TABLE "act_ru_external_job" ADD CONSTRAINT "act_ru_external_job_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table act_ru_history_job
-- ----------------------------
ALTER TABLE "act_ru_history_job" ADD CONSTRAINT "act_ru_history_job_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_identitylink
-- ----------------------------
CREATE INDEX "act_idx_athrz_procedef" ON "act_ru_identitylink" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ident_lnk_group" ON "act_ru_identitylink" USING btree (
  "group_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ident_lnk_scope" ON "act_ru_identitylink" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ident_lnk_scope_def" ON "act_ru_identitylink" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ident_lnk_sub_scope" ON "act_ru_identitylink" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ident_lnk_user" ON "act_ru_identitylink" USING btree (
  "user_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_idl_procinst" ON "act_ru_identitylink" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_tskass_task" ON "act_ru_identitylink" USING btree (
  "task_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_identitylink
-- ----------------------------
ALTER TABLE "act_ru_identitylink" ADD CONSTRAINT "act_ru_identitylink_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_job
-- ----------------------------
CREATE INDEX "act_idx_job_correlation_id" ON "act_ru_job" USING btree (
  "correlation_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_custom_values_id" ON "act_ru_job" USING btree (
  "custom_values_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_exception_stack_id" ON "act_ru_job" USING btree (
  "exception_stack_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_execution_id" ON "act_ru_job" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_proc_def_id" ON "act_ru_job" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_process_instance_id" ON "act_ru_job" USING btree (
  "process_instance_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_scope" ON "act_ru_job" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_scope_def" ON "act_ru_job" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_job_sub_scope" ON "act_ru_job" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_job
-- ----------------------------
ALTER TABLE "act_ru_job" ADD CONSTRAINT "act_ru_job_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_suspended_job
-- ----------------------------
CREATE INDEX "act_idx_sjob_scope" ON "act_ru_suspended_job" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_sjob_scope_def" ON "act_ru_suspended_job" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_sjob_sub_scope" ON "act_ru_suspended_job" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_suspended_job_correlation_id" ON "act_ru_suspended_job" USING btree (
  "correlation_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_suspended_job_custom_values_id" ON "act_ru_suspended_job" USING btree (
  "custom_values_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_suspended_job_exception_stack_id" ON "act_ru_suspended_job" USING btree (
  "exception_stack_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_suspended_job_execution_id" ON "act_ru_suspended_job" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_suspended_job_proc_def_id" ON "act_ru_suspended_job" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_suspended_job_process_instance_id" ON "act_ru_suspended_job" USING btree (
  "process_instance_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_suspended_job
-- ----------------------------
ALTER TABLE "act_ru_suspended_job" ADD CONSTRAINT "act_ru_suspended_job_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_task
-- ----------------------------
CREATE INDEX "act_idx_task_create" ON "act_ru_task" USING btree (
  "create_time_"  ASC NULLS LAST
);
CREATE INDEX "act_idx_task_exec" ON "act_ru_task" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_task_procdef" ON "act_ru_task" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_task_procinst" ON "act_ru_task" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_task_scope" ON "act_ru_task" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_task_scope_def" ON "act_ru_task" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_task_sub_scope" ON "act_ru_task" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_task
-- ----------------------------
ALTER TABLE "act_ru_task" ADD CONSTRAINT "act_ru_task_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_timer_job
-- ----------------------------
CREATE INDEX "act_idx_timer_job_correlation_id" ON "act_ru_timer_job" USING btree (
  "correlation_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_timer_job_custom_values_id" ON "act_ru_timer_job" USING btree (
  "custom_values_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_timer_job_duedate" ON "act_ru_timer_job" USING btree (
  "duedate_"  ASC NULLS LAST
);
CREATE INDEX "act_idx_timer_job_exception_stack_id" ON "act_ru_timer_job" USING btree (
  "exception_stack_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_timer_job_execution_id" ON "act_ru_timer_job" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_timer_job_proc_def_id" ON "act_ru_timer_job" USING btree (
  "proc_def_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_timer_job_process_instance_id" ON "act_ru_timer_job" USING btree (
  "process_instance_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_tjob_scope" ON "act_ru_timer_job" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_tjob_scope_def" ON "act_ru_timer_job" USING btree (
  "scope_definition_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_tjob_sub_scope" ON "act_ru_timer_job" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_timer_job
-- ----------------------------
ALTER TABLE "act_ru_timer_job" ADD CONSTRAINT "act_ru_timer_job_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table act_ru_variable
-- ----------------------------
CREATE INDEX "act_idx_ru_var_scope_id_type" ON "act_ru_variable" USING btree (
  "scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_ru_var_sub_id_type" ON "act_ru_variable" USING btree (
  "sub_scope_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "scope_type_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_var_bytearray" ON "act_ru_variable" USING btree (
  "bytearray_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_var_exe" ON "act_ru_variable" USING btree (
  "execution_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_var_procinst" ON "act_ru_variable" USING btree (
  "proc_inst_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "act_idx_variable_task_id" ON "act_ru_variable" USING btree (
  "task_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table act_ru_variable
-- ----------------------------
ALTER TABLE "act_ru_variable" ADD CONSTRAINT "act_ru_variable_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table flw_channel_definition
-- ----------------------------
CREATE UNIQUE INDEX "act_idx_channel_def_uniq" ON "flw_channel_definition" USING btree (
  "key_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "version_" "pg_catalog"."int4_ops" ASC NULLS LAST,
  "tenant_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table flw_channel_definition
-- ----------------------------
ALTER TABLE "flw_channel_definition" ADD CONSTRAINT "FLW_CHANNEL_DEFINITION_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table flw_ev_databasechangeloglock
-- ----------------------------
ALTER TABLE "flw_ev_databasechangeloglock" ADD CONSTRAINT "flw_ev_databasechangeloglock_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table flw_event_definition
-- ----------------------------
CREATE UNIQUE INDEX "act_idx_event_def_uniq" ON "flw_event_definition" USING btree (
  "key_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "version_" "pg_catalog"."int4_ops" ASC NULLS LAST,
  "tenant_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table flw_event_definition
-- ----------------------------
ALTER TABLE "flw_event_definition" ADD CONSTRAINT "FLW_EVENT_DEFINITION_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table flw_event_deployment
-- ----------------------------
ALTER TABLE "flw_event_deployment" ADD CONSTRAINT "FLW_EVENT_DEPLOYMENT_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table flw_event_resource
-- ----------------------------
ALTER TABLE "flw_event_resource" ADD CONSTRAINT "FLW_EVENT_RESOURCE_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Primary Key structure for table flw_ru_batch
-- ----------------------------
ALTER TABLE "flw_ru_batch" ADD CONSTRAINT "flw_ru_batch_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Indexes structure for table flw_ru_batch_part
-- ----------------------------
CREATE INDEX "flw_idx_batch_part" ON "flw_ru_batch_part" USING btree (
  "batch_id_" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table flw_ru_batch_part
-- ----------------------------
ALTER TABLE "flw_ru_batch_part" ADD CONSTRAINT "flw_ru_batch_part_pkey" PRIMARY KEY ("id_");

-- ----------------------------
-- Foreign Keys structure for table act_ge_bytearray
-- ----------------------------
ALTER TABLE "act_ge_bytearray" ADD CONSTRAINT "act_fk_bytearr_depl" FOREIGN KEY ("deployment_id_") REFERENCES "act_re_deployment" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_id_membership
-- ----------------------------
ALTER TABLE "act_id_membership" ADD CONSTRAINT "act_fk_memb_group" FOREIGN KEY ("group_id_") REFERENCES "act_id_group" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_id_membership" ADD CONSTRAINT "act_fk_memb_user" FOREIGN KEY ("user_id_") REFERENCES "act_id_user" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_id_priv_mapping
-- ----------------------------
ALTER TABLE "act_id_priv_mapping" ADD CONSTRAINT "act_fk_priv_mapping" FOREIGN KEY ("priv_id_") REFERENCES "act_id_priv" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_procdef_info
-- ----------------------------
ALTER TABLE "act_procdef_info" ADD CONSTRAINT "act_fk_info_json_ba" FOREIGN KEY ("info_json_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_procdef_info" ADD CONSTRAINT "act_fk_info_procdef" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_re_model
-- ----------------------------
ALTER TABLE "act_re_model" ADD CONSTRAINT "act_fk_model_deployment" FOREIGN KEY ("deployment_id_") REFERENCES "act_re_deployment" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_re_model" ADD CONSTRAINT "act_fk_model_source" FOREIGN KEY ("editor_source_value_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_re_model" ADD CONSTRAINT "act_fk_model_source_extra" FOREIGN KEY ("editor_source_extra_value_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_deadletter_job
-- ----------------------------
ALTER TABLE "act_ru_deadletter_job" ADD CONSTRAINT "act_fk_deadletter_job_custom_values" FOREIGN KEY ("custom_values_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_deadletter_job" ADD CONSTRAINT "act_fk_deadletter_job_exception" FOREIGN KEY ("exception_stack_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_deadletter_job" ADD CONSTRAINT "act_fk_deadletter_job_execution" FOREIGN KEY ("execution_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_deadletter_job" ADD CONSTRAINT "act_fk_deadletter_job_proc_def" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_deadletter_job" ADD CONSTRAINT "act_fk_deadletter_job_process_instance" FOREIGN KEY ("process_instance_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_event_subscr
-- ----------------------------
ALTER TABLE "act_ru_event_subscr" ADD CONSTRAINT "act_fk_event_exec" FOREIGN KEY ("execution_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_execution
-- ----------------------------
ALTER TABLE "act_ru_execution" ADD CONSTRAINT "act_fk_exe_parent" FOREIGN KEY ("parent_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_execution" ADD CONSTRAINT "act_fk_exe_procdef" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_execution" ADD CONSTRAINT "act_fk_exe_procinst" FOREIGN KEY ("proc_inst_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_execution" ADD CONSTRAINT "act_fk_exe_super" FOREIGN KEY ("super_exec_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_external_job
-- ----------------------------
ALTER TABLE "act_ru_external_job" ADD CONSTRAINT "act_fk_external_job_custom_values" FOREIGN KEY ("custom_values_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_external_job" ADD CONSTRAINT "act_fk_external_job_exception" FOREIGN KEY ("exception_stack_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_identitylink
-- ----------------------------
ALTER TABLE "act_ru_identitylink" ADD CONSTRAINT "act_fk_athrz_procedef" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_identitylink" ADD CONSTRAINT "act_fk_idl_procinst" FOREIGN KEY ("proc_inst_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_identitylink" ADD CONSTRAINT "act_fk_tskass_task" FOREIGN KEY ("task_id_") REFERENCES "act_ru_task" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_job
-- ----------------------------
ALTER TABLE "act_ru_job" ADD CONSTRAINT "act_fk_job_custom_values" FOREIGN KEY ("custom_values_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_job" ADD CONSTRAINT "act_fk_job_exception" FOREIGN KEY ("exception_stack_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_job" ADD CONSTRAINT "act_fk_job_execution" FOREIGN KEY ("execution_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_job" ADD CONSTRAINT "act_fk_job_proc_def" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_job" ADD CONSTRAINT "act_fk_job_process_instance" FOREIGN KEY ("process_instance_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_suspended_job
-- ----------------------------
ALTER TABLE "act_ru_suspended_job" ADD CONSTRAINT "act_fk_suspended_job_custom_values" FOREIGN KEY ("custom_values_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_suspended_job" ADD CONSTRAINT "act_fk_suspended_job_exception" FOREIGN KEY ("exception_stack_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_suspended_job" ADD CONSTRAINT "act_fk_suspended_job_execution" FOREIGN KEY ("execution_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_suspended_job" ADD CONSTRAINT "act_fk_suspended_job_proc_def" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_suspended_job" ADD CONSTRAINT "act_fk_suspended_job_process_instance" FOREIGN KEY ("process_instance_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_task
-- ----------------------------
ALTER TABLE "act_ru_task" ADD CONSTRAINT "act_fk_task_exe" FOREIGN KEY ("execution_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_task" ADD CONSTRAINT "act_fk_task_procdef" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_task" ADD CONSTRAINT "act_fk_task_procinst" FOREIGN KEY ("proc_inst_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_timer_job
-- ----------------------------
ALTER TABLE "act_ru_timer_job" ADD CONSTRAINT "act_fk_timer_job_custom_values" FOREIGN KEY ("custom_values_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_timer_job" ADD CONSTRAINT "act_fk_timer_job_exception" FOREIGN KEY ("exception_stack_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_timer_job" ADD CONSTRAINT "act_fk_timer_job_execution" FOREIGN KEY ("execution_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_timer_job" ADD CONSTRAINT "act_fk_timer_job_proc_def" FOREIGN KEY ("proc_def_id_") REFERENCES "act_re_procdef" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_timer_job" ADD CONSTRAINT "act_fk_timer_job_process_instance" FOREIGN KEY ("process_instance_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table act_ru_variable
-- ----------------------------
ALTER TABLE "act_ru_variable" ADD CONSTRAINT "act_fk_var_bytearray" FOREIGN KEY ("bytearray_id_") REFERENCES "act_ge_bytearray" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_variable" ADD CONSTRAINT "act_fk_var_exe" FOREIGN KEY ("execution_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "act_ru_variable" ADD CONSTRAINT "act_fk_var_procinst" FOREIGN KEY ("proc_inst_id_") REFERENCES "act_ru_execution" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table flw_ru_batch_part
-- ----------------------------
ALTER TABLE "flw_ru_batch_part" ADD CONSTRAINT "flw_fk_batch_part_parent" FOREIGN KEY ("batch_id_") REFERENCES "flw_ru_batch" ("id_") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- 流程分类表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_category";
CREATE TABLE "zz_flow_category" (
  "category_id" int8 NOT NULL,
  "tenant_id" int8,
  "app_code" varchar(64) COLLATE "pg_catalog"."default",
  "name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "code" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "show_order" int4 NOT NULL,
  "update_time" timestamp(6) NOT NULL,
  "update_user_id" int8 NOT NULL,
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL
);
COMMENT ON COLUMN "zz_flow_category"."category_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_category"."tenant_id" IS '租户Id';
COMMENT ON COLUMN "zz_flow_category"."app_code" IS '应用编码';
COMMENT ON COLUMN "zz_flow_category"."name" IS '显示名称';
COMMENT ON COLUMN "zz_flow_category"."code" IS '分类编码';
COMMENT ON COLUMN "zz_flow_category"."show_order" IS '实现顺序';
COMMENT ON COLUMN "zz_flow_category"."update_time" IS '更新时间';
COMMENT ON COLUMN "zz_flow_category"."update_user_id" IS '更新者Id';
COMMENT ON COLUMN "zz_flow_category"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_category"."create_user_id" IS '创建者Id';
COMMENT ON TABLE "zz_flow_category" IS '流程分类表';

CREATE INDEX "idx_zz_flow_category_tenant_id" ON "zz_flow_category" USING btree (
  "tenant_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_category_app_code" ON "zz_flow_category" USING btree (
  "app_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_category_code" ON "zz_flow_category" USING btree (
  "code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_category" ADD CONSTRAINT "zz_flow_category_pkey" PRIMARY KEY ("category_id");

-- ----------------------------
-- 流程管理表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_entry";
CREATE TABLE "zz_flow_entry" (
  "entry_id" int8 NOT NULL,
  "tenant_id" int8,
  "app_code" varchar(64) COLLATE "pg_catalog"."default",
  "process_definition_name" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
  "process_definition_key" varchar(150) COLLATE "pg_catalog"."default" NOT NULL,
  "category_id" int8 NOT NULL,
  "main_entry_publish_id" int8,
  "latest_publish_time" timestamp(6),
  "status" int4 NOT NULL,
  "bpmn_xml" text COLLATE "pg_catalog"."default",
  "diagram_type" int4 NOT NULL,
  "bind_form_type" int4 NOT NULL,
  "flow_type" int4 NOT NULL,
  "auto_param_json" varchar(2000) COLLATE "pg_catalog"."default",
  "page_id" int8,
  "default_form_id" int8,
  "default_router_name" varchar(255) COLLATE "pg_catalog"."default",
  "encoded_rule" varchar(255) COLLATE "pg_catalog"."default",
  "extension_data" varchar(3000) COLLATE "pg_catalog"."default",
  "image_data" varchar(2000) COLLATE "pg_catalog"."default",
  "update_time" timestamp(6) NOT NULL,
  "update_user_id" int8 NOT NULL,
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL
);
COMMENT ON COLUMN "zz_flow_entry"."entry_id" IS '主键';
COMMENT ON COLUMN "zz_flow_entry"."tenant_id" IS '租户Id';
COMMENT ON COLUMN "zz_flow_entry"."app_code" IS '应用编码';
COMMENT ON COLUMN "zz_flow_entry"."process_definition_name" IS '流程名称';
COMMENT ON COLUMN "zz_flow_entry"."process_definition_key" IS '流程标识Key';
COMMENT ON COLUMN "zz_flow_entry"."category_id" IS '流程分类';
COMMENT ON COLUMN "zz_flow_entry"."main_entry_publish_id" IS '工作流部署的发布主版本Id';
COMMENT ON COLUMN "zz_flow_entry"."latest_publish_time" IS '最新发布时间';
COMMENT ON COLUMN "zz_flow_entry"."status" IS '流程状态';
COMMENT ON COLUMN "zz_flow_entry"."bpmn_xml" IS '流程定义的xml';
COMMENT ON COLUMN "zz_flow_entry"."diagram_type" IS '流程图类型';
COMMENT ON COLUMN "zz_flow_entry"."bind_form_type" IS '绑定表单类型';
COMMENT ON COLUMN "zz_flow_entry"."flow_type" IS '流程类型';
COMMENT ON COLUMN "zz_flow_entry"."auto_param_json" IS '自动化流程的参数';
COMMENT ON COLUMN "zz_flow_entry"."page_id" IS '在线表单的页面Id';
COMMENT ON COLUMN "zz_flow_entry"."default_form_id" IS '在线表单Id';
COMMENT ON COLUMN "zz_flow_entry"."default_router_name" IS '静态表单的缺省路由名称';
COMMENT ON COLUMN "zz_flow_entry"."encoded_rule" IS '工单表编码字段的编码规则';
COMMENT ON COLUMN "zz_flow_entry"."extension_data" IS '流程的自定义扩展数据';
COMMENT ON COLUMN "zz_flow_entry"."image_data" IS '流程定义的图片';
COMMENT ON COLUMN "zz_flow_entry"."update_time" IS '更新时间';
COMMENT ON COLUMN "zz_flow_entry"."update_user_id" IS '更新者Id';
COMMENT ON COLUMN "zz_flow_entry"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_entry"."create_user_id" IS '创建者Id';
COMMENT ON TABLE "zz_flow_entry" IS '流程管理表';

CREATE INDEX "idx_zz_flow_entry_tenant_id" ON "zz_flow_entry" USING btree (
  "tenant_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_entry_category_id" ON "zz_flow_entry" USING btree (
  "category_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_entry_process_definition_name" ON "zz_flow_entry" USING btree (
  "process_definition_name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_entry_status" ON "zz_flow_entry" USING btree (
  "status" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_entry_app_code" ON "zz_flow_entry" USING btree (
  "app_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_entry_process_definition_key" ON "zz_flow_entry" USING btree (
  "process_definition_key" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_entry_type" ON "zz_flow_entry" USING btree (
  "flow_type" "pg_catalog"."int4_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_entry" ADD CONSTRAINT "zz_flow_entry_pkey" PRIMARY KEY ("entry_id");

-- ----------------------------
-- 流程发布表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_entry_publish";
CREATE TABLE "zz_flow_entry_publish" (
  "entry_publish_id" int8 NOT NULL,
  "entry_id" int8 NOT NULL,
  "process_definition_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "deploy_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "publish_version" int4 NOT NULL,
  "active_status" bool NOT NULL,
  "main_version" bool NOT NULL,
  "extension_data" varchar(3000) COLLATE "pg_catalog"."default",
  "create_user_id" int8 NOT NULL,
  "publish_time" timestamp(6) NOT NULL,
  "init_task_info" text COLLATE "pg_catalog"."default",
  "analyzed_node_json" text COLLATE "pg_catalog"."default"
);
COMMENT ON COLUMN "zz_flow_entry_publish"."entry_publish_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_entry_publish"."entry_id" IS '流程Id';
COMMENT ON COLUMN "zz_flow_entry_publish"."process_definition_id" IS '流程引擎的定义Id';
COMMENT ON COLUMN "zz_flow_entry_publish"."deploy_id" IS '流程引擎的部署Id';
COMMENT ON COLUMN "zz_flow_entry_publish"."publish_version" IS '发布版本';
COMMENT ON COLUMN "zz_flow_entry_publish"."active_status" IS '激活状态';
COMMENT ON COLUMN "zz_flow_entry_publish"."main_version" IS '是否为主版本';
COMMENT ON COLUMN "zz_flow_entry_publish"."extension_data" IS '流程的自定义扩展数据';
COMMENT ON COLUMN "zz_flow_entry_publish"."create_user_id" IS '创建者Id';
COMMENT ON COLUMN "zz_flow_entry_publish"."publish_time" IS '发布时间';
COMMENT ON COLUMN "zz_flow_entry_publish"."init_task_info" IS '第一个非开始节点任务的附加信息';
COMMENT ON COLUMN "zz_flow_entry_publish"."analyzed_node_json" IS '分析后的节点JSON信息';
COMMENT ON TABLE "zz_flow_entry_publish" IS '流程发布表';

CREATE INDEX "idx_zz_flow_entry_publish_entry_id" ON "zz_flow_entry_publish" USING btree (
  "entry_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "uk_zz_flow_entry_publish_process_definition_id" ON "zz_flow_entry_publish" USING btree (
  "process_definition_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_entry_publish" ADD CONSTRAINT "zz_flow_entry_publish_pkey" PRIMARY KEY ("entry_publish_id");

-- ----------------------------
-- 流程发布变量表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_entry_publish_variable";
CREATE TABLE "zz_flow_entry_publish_variable" (
  "variable_id" int8 NOT NULL,
  "entry_publish_id" int8 NOT NULL,
  "variable_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "show_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "variable_type" int4 NOT NULL,
  "bind_datasource_id" int8,
  "bind_relation_id" int8,
  "bind_column_id" int8,
  "builtin" bool NOT NULL
);
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."variable_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."entry_publish_id" IS '流程Id';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."variable_name" IS '变量名';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."show_name" IS '显示名';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."variable_type" IS '变量类型';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."bind_datasource_id" IS '绑定数据源Id';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."bind_relation_id" IS '绑定数据源关联Id';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."bind_column_id" IS '绑定字段Id';
COMMENT ON COLUMN "zz_flow_entry_publish_variable"."builtin" IS '是否内置';
COMMENT ON TABLE "zz_flow_entry_publish_variable" IS '流程发布变量表';

CREATE INDEX "idx_zz_flow_entry_publish_variable_entry_publish_id" ON "zz_flow_entry_publish_variable" USING btree (
  "entry_publish_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_entry_publish_variable" ADD CONSTRAINT "zz_flow_entry_publish_variable_pkey" PRIMARY KEY ("variable_id");

-- ----------------------------
-- 流程变量表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_entry_variable";
CREATE TABLE "zz_flow_entry_variable" (
  "variable_id" int8 NOT NULL,
  "entry_id" int8 NOT NULL,
  "variable_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "show_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "variable_type" int4 NOT NULL,
  "bind_datasource_id" int8,
  "bind_relation_id" int8,
  "bind_column_id" int8,
  "builtin" bool NOT NULL,
  "create_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_entry_variable"."variable_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_entry_variable"."entry_id" IS '流程Id';
COMMENT ON COLUMN "zz_flow_entry_variable"."variable_name" IS '变量名';
COMMENT ON COLUMN "zz_flow_entry_variable"."show_name" IS '显示名';
COMMENT ON COLUMN "zz_flow_entry_variable"."variable_type" IS '变量类型';
COMMENT ON COLUMN "zz_flow_entry_variable"."bind_datasource_id" IS '绑定数据源Id';
COMMENT ON COLUMN "zz_flow_entry_variable"."bind_relation_id" IS '绑定数据源关联Id';
COMMENT ON COLUMN "zz_flow_entry_variable"."bind_column_id" IS '绑定字段Id';
COMMENT ON COLUMN "zz_flow_entry_variable"."builtin" IS '是否内置';
COMMENT ON COLUMN "zz_flow_entry_variable"."create_time" IS '创建时间';
COMMENT ON TABLE "zz_flow_entry_variable" IS '流程变量表';

CREATE UNIQUE INDEX "uk_zz_flow_entry_variable_entry_id_variable_name" ON "zz_flow_entry_variable" USING btree (
  "entry_id" "pg_catalog"."int8_ops" ASC NULLS LAST,
  "variable_name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_entry_variable" ADD CONSTRAINT "zz_flow_entry_variable_pkey" PRIMARY KEY ("variable_id");

-- ----------------------------
-- 流程任务审批表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_task_comment";
CREATE TABLE "zz_flow_task_comment" (
  "id" int8 NOT NULL,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "task_id" varchar(64) COLLATE "pg_catalog"."default",
  "task_key" varchar(255) COLLATE "pg_catalog"."default",
  "task_name" varchar(512) COLLATE "pg_catalog"."default",
  "target_task_key" varchar(255) COLLATE "pg_catalog"."default",
  "execution_id" varchar(64) COLLATE "pg_catalog"."default",
  "multi_instance_exec_id" varchar(64) COLLATE "pg_catalog"."default",
  "approval_type" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
  "task_comment" varchar(1024) COLLATE "pg_catalog"."default",
  "delegate_assignee" varchar(512) COLLATE "pg_catalog"."default",
  "custom_business_data" text COLLATE "pg_catalog"."default",
  "head_image_url" varchar(1024) COLLATE "pg_catalog"."default",
  "delegate_username" varchar(512) COLLATE "pg_catalog"."default",
  "create_user_id" int8,
  "create_login_name" varchar(255) COLLATE "pg_catalog"."default",
  "create_username" varchar(255) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_task_comment"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_task_comment"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_task_comment"."task_id" IS '任务Id';
COMMENT ON COLUMN "zz_flow_task_comment"."task_key" IS '任务标识';
COMMENT ON COLUMN "zz_flow_task_comment"."task_name" IS '任务名称';
COMMENT ON COLUMN "zz_flow_task_comment"."target_task_key" IS '目标任务标识';
COMMENT ON COLUMN "zz_flow_task_comment"."execution_id" IS '任务的执行Id';
COMMENT ON COLUMN "zz_flow_task_comment"."multi_instance_exec_id" IS '会签任务的执行Id';
COMMENT ON COLUMN "zz_flow_task_comment"."approval_type" IS '审批类型';
COMMENT ON COLUMN "zz_flow_task_comment"."task_comment" IS '批注内容';
COMMENT ON COLUMN "zz_flow_task_comment"."delegate_assignee" IS '委托指定人，比如加签、转办等';
COMMENT ON COLUMN "zz_flow_task_comment"."custom_business_data" IS '自定义数据。开发者可自行扩展，推荐使用JSON格式数据';
COMMENT ON COLUMN "zz_flow_task_comment"."head_image_url" IS '审批用户头像';
COMMENT ON COLUMN "zz_flow_task_comment"."delegate_username" IS '委托用户';
COMMENT ON COLUMN "zz_flow_task_comment"."create_user_id" IS '创建者Id';
COMMENT ON COLUMN "zz_flow_task_comment"."create_login_name" IS '创建者登录名';
COMMENT ON COLUMN "zz_flow_task_comment"."create_username" IS '创建者用户名';
COMMENT ON COLUMN "zz_flow_task_comment"."create_time" IS '创建时间';
COMMENT ON TABLE "zz_flow_task_comment" IS '流程任务审批表';

CREATE INDEX "idx_zz_flow_task_comment_process_instance_id" ON "zz_flow_task_comment" USING btree (
  "process_instance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_task_comment_multi_instance_exec_id" ON "zz_flow_task_comment" USING btree (
  "multi_instance_exec_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_task_comment" ADD CONSTRAINT "zz_flow_task_comment_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程多实例任务审批流水表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_multi_instance_trans";
CREATE TABLE "zz_flow_multi_instance_trans" (
  "id" int8 NOT NULL,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "task_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "task_key" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "multi_instance_exec_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "execution_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "assignee_list" text COLLATE "pg_catalog"."default",
  "delegate_username" varchar(512) COLLATE "pg_catalog"."default",
  "create_user_id" int8 NOT NULL,
  "create_login_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "create_username" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "create_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."task_id" IS '任务Id';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."task_key" IS '任务标识';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."multi_instance_exec_id" IS '会签任务的执行Id';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."execution_id" IS '任务的执行Id';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."assignee_list" IS '会签指派人列表';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."delegate_username" IS '委托用户';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."create_user_id" IS '创建者Id';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."create_login_name" IS '创建者登录名';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."create_username" IS '创建者用户名';
COMMENT ON COLUMN "zz_flow_multi_instance_trans"."create_time" IS '创建时间';
COMMENT ON TABLE "zz_flow_multi_instance_trans" IS '流程多实例任务审批流水表';

CREATE UNIQUE INDEX "uk_execution_id_task_id" ON "zz_flow_multi_instance_trans" USING btree (
  "execution_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "task_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_multi_instance_exec_id" ON "zz_flow_multi_instance_trans" USING btree (
  "multi_instance_exec_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_multi_instance_trans" ADD CONSTRAINT "zz_flow_multi_instance_trans_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程流程图任务扩展表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_task_ext";
CREATE TABLE "zz_flow_task_ext" (
  "process_definition_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "task_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "operation_list_json" text COLLATE "pg_catalog"."default",
  "variable_list_json" text COLLATE "pg_catalog"."default",
  "assignee_list_json" text COLLATE "pg_catalog"."default",
  "group_type" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "dept_post_list_json" varchar(1024) COLLATE "pg_catalog"."default",
  "role_ids" varchar(1024) COLLATE "pg_catalog"."default",
  "dept_ids" varchar(1024) COLLATE "pg_catalog"."default",
  "candidate_usernames" varchar(4000) COLLATE "pg_catalog"."default",
  "copy_list_json" varchar(4000) COLLATE "pg_catalog"."default",
  "api_json" varchar(4000) COLLATE "pg_catalog"."default",
  "extra_data_json" text COLLATE "pg_catalog"."default",
  "auto_config_json" text COLLATE "pg_catalog"."default",
  "business_operation_json" text COLLATE "pg_catalog"."default"
);
COMMENT ON COLUMN "zz_flow_task_ext"."process_definition_id" IS '流程引擎的定义Id';
COMMENT ON COLUMN "zz_flow_task_ext"."task_id" IS '流程引擎任务Id';
COMMENT ON COLUMN "zz_flow_task_ext"."operation_list_json" IS '操作列表JSON';
COMMENT ON COLUMN "zz_flow_task_ext"."variable_list_json" IS '变量列表JSON';
COMMENT ON COLUMN "zz_flow_task_ext"."assignee_list_json" IS '存储多实例的assigneeList的JSON';
COMMENT ON COLUMN "zz_flow_task_ext"."group_type" IS '分组类型';
COMMENT ON COLUMN "zz_flow_task_ext"."dept_post_list_json" IS '保存岗位相关的数据';
COMMENT ON COLUMN "zz_flow_task_ext"."role_ids" IS '保存角色Id数据';
COMMENT ON COLUMN "zz_flow_task_ext"."dept_ids" IS '保存部门Id数据';
COMMENT ON COLUMN "zz_flow_task_ext"."candidate_usernames" IS '保存候选组用户名数据';
COMMENT ON COLUMN "zz_flow_task_ext"."copy_list_json" IS '抄送相关的数据';
COMMENT ON COLUMN "zz_flow_task_ext"."api_json" IS '审批任务选择候选用户的API配置';
COMMENT ON COLUMN "zz_flow_task_ext"."extra_data_json" IS '用户任务的扩展属性，存储为JSON的字符串格式';
COMMENT ON COLUMN "zz_flow_task_ext"."auto_config_json" IS '自动化任务配置数据，存储为JSON的字符串格式';
COMMENT ON COLUMN "zz_flow_task_ext"."business_operation_json" IS '流程任务和业务交互操作的配置数据，存储为JSON的字符串格式';
COMMENT ON TABLE "zz_flow_task_ext" IS '流程流程图任务扩展表';

ALTER TABLE "zz_flow_task_ext" ADD CONSTRAINT "zz_flow_task_ext_pkey" PRIMARY KEY ("process_definition_id", "task_id");

-- ----------------------------
-- 流程工单表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_work_order";
CREATE TABLE "zz_flow_work_order" (
  "work_order_id" int8 NOT NULL,
  "tenant_id" int8,
  "app_code" varchar(64) COLLATE "pg_catalog"."default",
  "work_order_code" varchar(255) COLLATE "pg_catalog"."default",
  "process_definition_key" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
  "process_definition_name" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
  "process_definition_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "online_table_id" int8,
  "table_name" varchar(128) COLLATE "pg_catalog"."default",
  "business_key" varchar(128) COLLATE "pg_catalog"."default",
  "task_id" varchar(64) COLLATE "pg_catalog"."default",
  "task_name" varchar(255) COLLATE "pg_catalog"."default",
  "task_definition_key" varchar(255) COLLATE "pg_catalog"."default",
  "latest_approval_status" int4,
  "flow_status" int4 NOT NULL,
  "finished_with_agree" bool,
  "summary_data" varchar(1000) COLLATE "pg_catalog"."default" NOT NULL,
  "submit_username" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "dept_id" int8 NOT NULL,
  "update_time" timestamp(6) NOT NULL,
  "update_user_id" int8 NOT NULL,
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL,
  "deleted_flag" int4 NOT NULL
);
COMMENT ON COLUMN "zz_flow_work_order"."work_order_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_work_order"."tenant_id" IS '租户Id';
COMMENT ON COLUMN "zz_flow_work_order"."app_code" IS '应用编码';
COMMENT ON COLUMN "zz_flow_work_order"."work_order_code" IS '工单编码字段';
COMMENT ON COLUMN "zz_flow_work_order"."process_definition_key" IS '流程定义标识';
COMMENT ON COLUMN "zz_flow_work_order"."process_definition_name" IS '流程名称';
COMMENT ON COLUMN "zz_flow_work_order"."process_definition_id" IS '流程引擎的定义Id';
COMMENT ON COLUMN "zz_flow_work_order"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_work_order"."online_table_id" IS '在线表单的主表Id';
COMMENT ON COLUMN "zz_flow_work_order"."table_name" IS '静态表单工作流所使用的数据表';
COMMENT ON COLUMN "zz_flow_work_order"."business_key" IS '业务主键值';
COMMENT ON COLUMN "zz_flow_work_order"."task_id" IS '未完成的任务Id';
COMMENT ON COLUMN "zz_flow_work_order"."task_name" IS '未完成的任务名称';
COMMENT ON COLUMN "zz_flow_work_order"."task_definition_key" IS '未完成的任务标识';
COMMENT ON COLUMN "zz_flow_work_order"."latest_approval_status" IS '最近的审批状态';
COMMENT ON COLUMN "zz_flow_work_order"."flow_status" IS '流程状态';
COMMENT ON COLUMN "zz_flow_work_order"."finished_with_agree" IS '流程以同意结束';
COMMENT ON COLUMN "zz_flow_work_order"."summary_data" IS '流程实例摘要数据';
COMMENT ON COLUMN "zz_flow_work_order"."submit_username" IS '提交用户登录名称';
COMMENT ON COLUMN "zz_flow_work_order"."dept_id" IS '提交用户所在部门Id';
COMMENT ON COLUMN "zz_flow_work_order"."update_time" IS '更新时间';
COMMENT ON COLUMN "zz_flow_work_order"."update_user_id" IS '更新者Id';
COMMENT ON COLUMN "zz_flow_work_order"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_work_order"."create_user_id" IS '创建者Id';
COMMENT ON COLUMN "zz_flow_work_order"."deleted_flag" IS '逻辑删除标记(1: 正常 -1: 已删除)';
COMMENT ON TABLE "zz_flow_work_order" IS '流程工单表';

CREATE INDEX "idx_zz_flow_work_order_tenant_id" ON "zz_flow_work_order" USING btree (
  "tenant_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_work_order_app_code" ON "zz_flow_work_order" USING btree (
  "app_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_work_order_table_name" ON "zz_flow_work_order" USING btree (
  "table_name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_work_order_business_key" ON "zz_flow_work_order" USING btree (
  "business_key" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_work_order_create_time" ON "zz_flow_work_order" USING btree (
  "create_time"  ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_work_order_create_user_id" ON "zz_flow_work_order" USING btree (
  "create_user_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_work_order_dept_id" ON "zz_flow_work_order" USING btree (
  "dept_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_work_order_process_definition_key" ON "zz_flow_work_order" USING btree (
  "process_definition_key" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "uk_zz_process_instance_id" ON "zz_flow_work_order" USING btree (
  "process_instance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "uk_zz_work_order_code" ON "zz_flow_work_order" USING btree (
  "work_order_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_work_order" ADD CONSTRAINT "zz_flow_work_order_pkey" PRIMARY KEY ("work_order_id");

-- ----------------------------
-- 流程工单扩展表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_work_order_ext";
CREATE TABLE "zz_flow_work_order_ext" (
  "id" int8 NOT NULL,
  "work_order_id" int8 NOT NULL,
  "draft_data" text COLLATE "pg_catalog"."default",
  "business_data" text COLLATE "pg_catalog"."default",
  "update_time" timestamp(6) NOT NULL,
  "update_user_id" int8 NOT NULL,
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL,
  "deleted_flag" int4 NOT NULL
);
COMMENT ON COLUMN "zz_flow_work_order_ext"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_work_order_ext"."work_order_id" IS '工单Id';
COMMENT ON COLUMN "zz_flow_work_order_ext"."draft_data" IS '草稿数据';
COMMENT ON COLUMN "zz_flow_work_order_ext"."business_data" IS '业务数据';
COMMENT ON COLUMN "zz_flow_work_order_ext"."update_time" IS '更新时间';
COMMENT ON COLUMN "zz_flow_work_order_ext"."update_user_id" IS '更新者Id';
COMMENT ON COLUMN "zz_flow_work_order_ext"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_work_order_ext"."create_user_id" IS '创建者Id';
COMMENT ON COLUMN "zz_flow_work_order_ext"."deleted_flag" IS '逻辑删除标记(1: 正常 -1: 已删除)';
COMMENT ON TABLE "zz_flow_work_order_ext" IS '流程工单扩展表';

CREATE INDEX "idx_zz_flow_work_order_ext_work_order_id" ON "zz_flow_work_order_ext" USING btree (
  "work_order_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_work_order_ext" ADD CONSTRAINT "zz_flow_work_order_ext_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程消息通知表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_message";
CREATE TABLE "zz_flow_message" (
  "message_id" int8 NOT NULL,
  "tenant_id" int8,
  "app_code" varchar(64) COLLATE "pg_catalog"."default",
  "message_type" int2 NOT NULL,
  "message_content" varchar(1024) COLLATE "pg_catalog"."default",
  "remind_count" int4,
  "work_order_id" int8,
  "process_definition_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "process_definition_key" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "process_definition_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "process_instance_id" varchar(255) COLLATE "pg_catalog"."default",
  "process_instance_initiator" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL,
  "task_id" varchar(255) COLLATE "pg_catalog"."default",
  "task_definition_key" varchar(255) COLLATE "pg_catalog"."default",
  "task_name" varchar(255) COLLATE "pg_catalog"."default",
  "task_start_time" timestamp(6),
  "task_finished" bool NOT NULL DEFAULT false,
  "task_assignee" varchar(64) COLLATE "pg_catalog"."default",
  "business_data_shot" text COLLATE "pg_catalog"."default",
  "online_form_data" bool,
  "update_time" timestamp(6) NOT NULL,
  "update_user_id" int8 NOT NULL,
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL,
  "create_username" varchar(255) COLLATE "pg_catalog"."default" NOT NULL
);
COMMENT ON COLUMN "zz_flow_message"."message_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_message"."tenant_id" IS '租户Id';
COMMENT ON COLUMN "zz_flow_message"."app_code" IS '应用Id';
COMMENT ON COLUMN "zz_flow_message"."message_type" IS '消息类型';
COMMENT ON COLUMN "zz_flow_message"."message_content" IS '消息内容';
COMMENT ON COLUMN "zz_flow_message"."remind_count" IS '催办次数';
COMMENT ON COLUMN "zz_flow_message"."work_order_id" IS '工单Id';
COMMENT ON COLUMN "zz_flow_message"."process_definition_id" IS '流程定义Id';
COMMENT ON COLUMN "zz_flow_message"."process_definition_key" IS '流程定义标识';
COMMENT ON COLUMN "zz_flow_message"."process_definition_name" IS '流程定义名称';
COMMENT ON COLUMN "zz_flow_message"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_message"."process_instance_initiator" IS '流程实例发起者';
COMMENT ON COLUMN "zz_flow_message"."task_id" IS '流程任务Id';
COMMENT ON COLUMN "zz_flow_message"."task_definition_key" IS '流程任务定义标识';
COMMENT ON COLUMN "zz_flow_message"."task_name" IS '流程任务名称';
COMMENT ON COLUMN "zz_flow_message"."task_start_time" IS '任务开始时间';
COMMENT ON COLUMN "zz_flow_message"."task_finished" IS '任务是否已完成';
COMMENT ON COLUMN "zz_flow_message"."task_assignee" IS '任务指派人登录名';
COMMENT ON COLUMN "zz_flow_message"."business_data_shot" IS '业务数据快照';
COMMENT ON COLUMN "zz_flow_message"."online_form_data" IS '是否为在线表单消息数据';
COMMENT ON COLUMN "zz_flow_message"."update_time" IS '更新时间';
COMMENT ON COLUMN "zz_flow_message"."update_user_id" IS '更新者Id';
COMMENT ON COLUMN "zz_flow_message"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_message"."create_user_id" IS '创建者Id';
COMMENT ON COLUMN "zz_flow_message"."create_username" IS '创建者显示名';
COMMENT ON TABLE "zz_flow_message" IS '流程消息通知表';

CREATE INDEX "idx_zz_flow_message_tenant_id" ON "zz_flow_message" USING btree (
  "tenant_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_message_app_code" ON "zz_flow_message" USING btree (
  "app_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_message_message_type" ON "zz_flow_message" USING btree (
  "message_type" "pg_catalog"."int2_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_message_task_assignee" ON "zz_flow_message" USING btree (
  "task_assignee" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_message_process_instance_id" ON "zz_flow_message" USING btree (
  "process_instance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_message_task_id" ON "zz_flow_message" USING btree (
  "task_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_message_update_time" ON "zz_flow_message" USING btree (
  "update_time"  ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_message_task_finished" ON "zz_flow_message" USING btree (
  "task_finished" "pg_catalog"."bool_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_message" ADD CONSTRAINT "zz_flow_message_pkey" PRIMARY KEY ("message_id");

-- ----------------------------
-- 流程消息通知候选人表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_msg_candidate_identity";
CREATE TABLE "zz_flow_msg_candidate_identity" (
  "id" int8 NOT NULL,
  "message_id" int8 NOT NULL,
  "candidate_type" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
  "candidate_id" varchar(32) COLLATE "pg_catalog"."default" NOT NULL
);
COMMENT ON COLUMN "zz_flow_msg_candidate_identity"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_msg_candidate_identity"."message_id" IS '流程任务Id';
COMMENT ON COLUMN "zz_flow_msg_candidate_identity"."candidate_type" IS '候选身份类型';
COMMENT ON COLUMN "zz_flow_msg_candidate_identity"."candidate_id" IS '候选身份Id';
COMMENT ON TABLE "zz_flow_msg_candidate_identity" IS '流程消息通知候选人表';

CREATE INDEX "idx_zz_flow_msg_candidate_identity_candidate_id" ON "zz_flow_msg_candidate_identity" USING btree (
  "candidate_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_msg_candidate_identity_message_id" ON "zz_flow_msg_candidate_identity" USING btree (
  "message_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_msg_candidate_identity" ADD CONSTRAINT "zz_flow_msg_candidate_identity_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程消息候选人操作表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_msg_identity_operation";
CREATE TABLE "zz_flow_msg_identity_operation" (
  "id" int8 NOT NULL,
  "message_id" int8 NOT NULL,
  "login_name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "operation_type" int4 NOT NULL,
  "operation_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_msg_identity_operation"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_msg_identity_operation"."message_id" IS '流程任务Id';
COMMENT ON COLUMN "zz_flow_msg_identity_operation"."login_name" IS '用户登录名';
COMMENT ON COLUMN "zz_flow_msg_identity_operation"."operation_type" IS '操作类型';
COMMENT ON COLUMN "zz_flow_msg_identity_operation"."operation_time" IS '操作时间';
COMMENT ON TABLE "zz_flow_msg_identity_operation" IS '流程消息候选人操作表';

CREATE INDEX "idx_flow_msg_identity_operation_login_name" ON "zz_flow_msg_identity_operation" USING btree (
  "login_name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_flow_msg_identity_operation_message_id" ON "zz_flow_msg_identity_operation" USING btree (
  "message_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_msg_identity_operation" ADD CONSTRAINT "zz_flow_msg_identity_operation_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程变量日志表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_variable_log";
CREATE TABLE "zz_flow_variable_log" (
  "id" int8 NOT NULL,
  "process_definition_key" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "task_key" varchar(255) COLLATE "pg_catalog"."default",
  "variable_data" text COLLATE "pg_catalog"."default" NOT NULL,
  "create_time" timestamp(6) NOT NULL,
  "expired_time" timestamp(6)
);
COMMENT ON COLUMN "zz_flow_variable_log"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_variable_log"."process_definition_key" IS '流程定义标识';
COMMENT ON COLUMN "zz_flow_variable_log"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_variable_log"."task_key" IS '未完成的任务标识';
COMMENT ON COLUMN "zz_flow_variable_log"."variable_data" IS '变量数据';
COMMENT ON COLUMN "zz_flow_variable_log"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_variable_log"."expired_time" IS '过期时间';
COMMENT ON TABLE "zz_flow_variable_log" IS '流程变量日志表';

CREATE INDEX "idx_process_instance_id" ON "zz_flow_variable_log" USING btree (
  "process_instance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "task_key" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_variable_log" ADD CONSTRAINT "zz_flow_variable_log_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 路由表单工作流API请求日志表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_api_request_log";
CREATE TABLE "zz_flow_api_request_log" (
  "id" int8 NOT NULL,
  "request_id" varchar(512) COLLATE "pg_catalog"."default" NOT NULL,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "business_key" varchar(128) COLLATE "pg_catalog"."default",
  "task_id" varchar(64) COLLATE "pg_catalog"."default",
  "task_key" varchar(255) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL
);
COMMENT ON COLUMN "zz_flow_api_request_log"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_api_request_log"."request_id" IS '单次请求Id';
COMMENT ON COLUMN "zz_flow_api_request_log"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_api_request_log"."task_id" IS '任务Id';
COMMENT ON COLUMN "zz_flow_api_request_log"."task_key" IS '任务标识';
COMMENT ON COLUMN "zz_flow_api_request_log"."business_key" IS '业务主键值';
COMMENT ON COLUMN "zz_flow_api_request_log"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_api_request_log"."create_user_id" IS '创建者Id';
COMMENT ON TABLE "zz_flow_api_request_log" IS '路由表单工作流API请求日志表';

CREATE INDEX "idx_api_request_log_id" ON "zz_flow_api_request_log" USING btree (
  "request_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_api_request_log" ADD CONSTRAINT "zz_flow_api_request_log_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程任务超时作业表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_task_timeout_job";
CREATE TABLE "zz_flow_task_timeout_job" (
  "id" int8 NOT NULL,
  "process_definition_id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "task_key" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "task_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "timeout_hours" int4 NOT NULL,
  "handle_way" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "default_assignee" varchar(255) COLLATE "pg_catalog"."default",
  "error_message" varchar(1024) COLLATE "pg_catalog"."default",
  "status" int4 NOT NULL,
  "exec_time" timestamp(6),
  "create_time" timestamp(6) NOT NULL,
  "update_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_task_timeout_job"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."process_definition_id" IS '流程定义Id';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."task_key" IS '任务标识';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."task_id" IS '任务Id';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."timeout_hours" IS '超时的小时数';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."handle_way" IS '超时处理方式';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."default_assignee" IS '超时处理缺省用户名';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."error_message" IS '错误信息';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."status" IS '执行状态';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."exec_time" IS '执行时间';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_task_timeout_job"."update_time" IS '更新时间';
COMMENT ON TABLE "zz_flow_task_timeout_job" IS '流程任务超时作业表';

CREATE INDEX "idx_task_to_job_exec_time" ON "zz_flow_task_timeout_job" USING btree (
  "exec_time"  ASC NULLS LAST
);
CREATE INDEX "idx_task_to_job_proc_inst_id" ON "zz_flow_task_timeout_job" USING btree (
  "process_instance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_task_to_job_status" ON "zz_flow_task_timeout_job" USING btree (
  "status" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "idx_task_to_job_task_id" ON "zz_flow_task_timeout_job" USING btree (
  "task_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_task_timeout_job" ADD CONSTRAINT "zz_flow_task_timeout_job_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程处理事务事件生产者流水表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_trans_producer";
CREATE TABLE "zz_flow_trans_producer" (
  "trans_id" int8 NOT NULL,
  "app_code" varchar(64) COLLATE "pg_catalog"."default",
  "dblink_id" int8,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "execution_id" varchar(64) COLLATE "pg_catalog"."default",
  "task_id" varchar(64) COLLATE "pg_catalog"."default",
  "task_key" varchar(255) COLLATE "pg_catalog"."default",
  "task_name" varchar(512) COLLATE "pg_catalog"."default",
  "task_comment" varchar(1024) COLLATE "pg_catalog"."default",
  "url" varchar(256) COLLATE "pg_catalog"."default",
  "init_method" varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
  "trace_id" varchar(64) COLLATE "pg_catalog"."default",
  "sql_data" text COLLATE "pg_catalog"."default",
  "auto_task_config" text COLLATE "pg_catalog"."default",
  "try_times" int4 NOT NULL,
  "error_reason" text COLLATE "pg_catalog"."default",
  "create_login_name" varchar(255) COLLATE "pg_catalog"."default",
  "create_username" varchar(512) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_trans_producer"."trans_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_trans_producer"."app_code" IS '应用Id';
COMMENT ON COLUMN "zz_flow_trans_producer"."dblink_id" IS '数据库链接Id';
COMMENT ON COLUMN "zz_flow_trans_producer"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_trans_producer"."execution_id" IS '流程执行实例Id';
COMMENT ON COLUMN "zz_flow_trans_producer"."task_id" IS '任务Id';
COMMENT ON COLUMN "zz_flow_trans_producer"."task_key" IS '任务标识';
COMMENT ON COLUMN "zz_flow_trans_producer"."task_name" IS '任务名称';
COMMENT ON COLUMN "zz_flow_trans_producer"."task_comment" IS '批注内容';
COMMENT ON COLUMN "zz_flow_trans_producer"."url" IS '当前请求的url';
COMMENT ON COLUMN "zz_flow_trans_producer"."init_method" IS '创建该事务性事件对象的初始方法';
COMMENT ON COLUMN "zz_flow_trans_producer"."trace_id" IS '当前请求的traceId';
COMMENT ON COLUMN "zz_flow_trans_producer"."sql_data" IS '和SQL操作相关的数据';
COMMENT ON COLUMN "zz_flow_trans_producer"."auto_task_config" IS '自动化任务需要执行的数据';
COMMENT ON COLUMN "zz_flow_trans_producer"."try_times" IS '尝试次数';
COMMENT ON COLUMN "zz_flow_trans_producer"."error_reason" IS '提交业务数据时的错误信息';
COMMENT ON COLUMN "zz_flow_trans_producer"."create_login_name" IS '创建者登录名';
COMMENT ON COLUMN "zz_flow_trans_producer"."create_username" IS '创建者中文用户名';
COMMENT ON COLUMN "zz_flow_trans_producer"."create_time" IS '创建时间';
COMMENT ON TABLE "zz_flow_trans_producer" IS '流程处理事务事件生产者流水表';

CREATE INDEX "idx_app_code" ON "zz_flow_trans_producer" USING btree (
  "app_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_pt_instance_id" ON "zz_flow_trans_producer" USING btree (
  "process_instance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_trans_producer" ADD CONSTRAINT "zz_flow_trans_producer_pkey" PRIMARY KEY ("trans_id");

-- ----------------------------
-- 流程处理事务事件消费者流水表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_trans_consumer";
CREATE TABLE "zz_flow_trans_consumer" (
  "trans_id" int8 NOT NULL,
  "create_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_trans_consumer"."trans_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_trans_consumer"."create_time" IS '创建时间';
COMMENT ON TABLE "zz_flow_trans_consumer" IS '流程处理事务事件消费者流水表';

ALTER TABLE "zz_flow_trans_consumer" ADD CONSTRAINT "zz_flow_trans_consumer_pkey" PRIMARY KEY ("trans_id");

-- ----------------------------
-- 自动化流程数据库链接表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_dblink";
CREATE TABLE "zz_flow_dblink" (
  "dblink_id" int8 NOT NULL,
  "app_code" varchar(64) COLLATE "pg_catalog"."default",
  "dblink_name" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "dblink_description" varchar(512) COLLATE "pg_catalog"."default",
  "dblink_type" int4 NOT NULL,
  "configuration" varchar(20000) COLLATE "pg_catalog"."default" NOT NULL,
  "update_time" timestamp(6) NOT NULL,
  "update_user_id" int8 NOT NULL,
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL
);
COMMENT ON COLUMN "zz_flow_dblink"."dblink_id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_dblink"."app_code" IS '应用编码';
COMMENT ON COLUMN "zz_flow_dblink"."dblink_name" IS '链接中文名称';
COMMENT ON COLUMN "zz_flow_dblink"."dblink_description" IS '链接描述';
COMMENT ON COLUMN "zz_flow_dblink"."dblink_type" IS '数据源类型';
COMMENT ON COLUMN "zz_flow_dblink"."configuration" IS '配置信息';
COMMENT ON COLUMN "zz_flow_dblink"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_dblink"."create_user_id" IS '创建者';
COMMENT ON COLUMN "zz_flow_dblink"."update_time" IS '更新时间';
COMMENT ON COLUMN "zz_flow_dblink"."update_user_id" IS '更新者';
COMMENT ON TABLE "zz_flow_dblink" IS '在线表单数据库链接表';

CREATE INDEX "idx_zz_flow_dblink_app_code" ON "zz_flow_dblink" USING btree (
  "app_code" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_dblink_type" ON "zz_flow_dblink" USING btree (
  "dblink_type" "pg_catalog"."int4_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_dblink" ADD CONSTRAINT "zz_flow_dblink_pkey" PRIMARY KEY ("dblink_id");

-- ----------------------------
-- 自动化任务变量日志表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_auto_variable_log";
CREATE TABLE "zz_flow_auto_variable_log" (
  "id" int8 NOT NULL,
  "process_instance_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "execution_id" varchar(64) COLLATE "pg_catalog"."default",
  "task_id" varchar(64) COLLATE "pg_catalog"."default",
  "task_key" varchar(255) COLLATE "pg_catalog"."default",
  "trace_id" varchar(512) COLLATE "pg_catalog"."default",
  "variable_data" text COLLATE "pg_catalog"."default",
  "create_time" timestamp(6) NOT NULL
);
COMMENT ON COLUMN "zz_flow_auto_variable_log"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_auto_variable_log"."process_instance_id" IS '流程实例Id';
COMMENT ON COLUMN "zz_flow_auto_variable_log"."execution_id" IS '执行实例Id';
COMMENT ON COLUMN "zz_flow_auto_variable_log"."task_id" IS '任务Id';
COMMENT ON COLUMN "zz_flow_auto_variable_log"."task_key" IS '任务标识';
COMMENT ON COLUMN "zz_flow_auto_variable_log"."trace_id" IS '当前请求的traceId';
COMMENT ON COLUMN "zz_flow_auto_variable_log"."variable_data" IS '变量数据';
COMMENT ON COLUMN "zz_flow_auto_variable_log"."create_time" IS '创建时间';
COMMENT ON TABLE "zz_flow_auto_variable_log" IS '自动化流程变量日志表';

CREATE INDEX "idx_auto_process_instance_id" ON "zz_flow_auto_variable_log" USING btree (
  "process_instance_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "task_key" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_auto_variable_log" ADD CONSTRAINT "zz_flow_auto_variable_log_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程委托用户表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_delegate_user";
CREATE TABLE "zz_flow_delegate_user" (
  "id" int8 NOT NULL,
  "delegate_users" varchar(2000) COLLATE "pg_catalog"."default" NOT NULL,
  "process_definition_keys" varchar(2000) COLLATE "pg_catalog"."default",
  "delegate_scope" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "start_time" timestamp(6) NOT NULL,
  "end_time" timestamp(6) NOT NULL,
  "memo" varchar(500) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6) NOT NULL,
  "create_user_id" int8 NOT NULL,
  "create_login_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "create_show_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "update_time" timestamp(6) NOT NULL,
  "update_user_id" int8 NOT NULL
);
COMMENT ON COLUMN "zz_flow_delegate_user"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_delegate_user"."delegate_users" IS '委托用户的登录名，多个用户之间逗号分隔';
COMMENT ON COLUMN "zz_flow_delegate_user"."process_definition_keys" IS '流程定义标识，多个流程之间逗号分隔';
COMMENT ON COLUMN "zz_flow_delegate_user"."delegate_scope" IS '委托范围';
COMMENT ON COLUMN "zz_flow_delegate_user"."start_time" IS '开始时间';
COMMENT ON COLUMN "zz_flow_delegate_user"."end_time" IS '结束时间';
COMMENT ON COLUMN "zz_flow_delegate_user"."memo" IS '委托说明';
COMMENT ON COLUMN "zz_flow_delegate_user"."create_time" IS '创建时间';
COMMENT ON COLUMN "zz_flow_delegate_user"."create_user_id" IS '创建者';
COMMENT ON COLUMN "zz_flow_delegate_user"."create_login_name" IS '创建用户登录名';
COMMENT ON COLUMN "zz_flow_delegate_user"."create_show_name" IS '创建用户显示名';
COMMENT ON COLUMN "zz_flow_delegate_user"."update_time" IS '修改时间';
COMMENT ON COLUMN "zz_flow_delegate_user"."update_user_id" IS '更新者';
COMMENT ON TABLE "zz_flow_delegate_user" IS '流程委托用户表';

CREATE INDEX "idx_zz_flow_delegate_user_create_user_id" ON "zz_flow_delegate_user" USING btree (
  "create_user_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_delegate_user_end_time" ON "zz_flow_delegate_user" USING btree (
  "end_time"  ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_delegate_user_start_time" ON "zz_flow_delegate_user" USING btree (
  "start_time"  ASC NULLS LAST
);
ALTER TABLE "zz_flow_delegate_user" ADD CONSTRAINT "zz_flow_delegate_user_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- 流程被委托用户表
-- ----------------------------
DROP TABLE IF EXISTS "zz_flow_delegated_user";
CREATE TABLE "zz_flow_delegated_user" (
  "id" int8 NOT NULL,
  "delegate_id" int8 NOT NULL,
  "user_id" int8 NOT NULL,
  "confirm_status" int4 NOT NULL
);
COMMENT ON COLUMN "zz_flow_delegated_user"."id" IS '主键Id';
COMMENT ON COLUMN "zz_flow_delegated_user"."delegate_id" IS '委托数据Id';
COMMENT ON COLUMN "zz_flow_delegated_user"."user_id" IS '用户Id';
COMMENT ON COLUMN "zz_flow_delegated_user"."confirm_status" IS '确认状态';
COMMENT ON TABLE "zz_flow_delegated_user" IS '流程被委托用户表';

CREATE INDEX "idx_zz_flow_delegated_user_confirm_status" ON "zz_flow_delegated_user" USING btree (
  "confirm_status" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_delegated_user_delegate_id" ON "zz_flow_delegated_user" USING btree (
  "delegate_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_zz_flow_delegated_user_user_id" ON "zz_flow_delegated_user" USING btree (
  "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
ALTER TABLE "zz_flow_delegated_user" ADD CONSTRAINT "zz_flow_delegated_user_pkey" PRIMARY KEY ("id");

